Set up a scheduled job?
One solution that I have employed is to do this:
1) Create a custom management command, e.g.
python manage.py my_cool_command
2) Use cron
(on Linux) or at
(on Windows) to run my command at the required times.
This is a simple solution that doesn't require installing a heavy AMQP stack. However there are nice advantages to using something like Celery, mentioned in the other answers. In particular, with Celery it is nice to not have to spread your application logic out into crontab files. However the cron solution works quite nicely for a small to medium sized application and where you don't want a lot of external dependencies.
EDIT:
In later version of windows the at
command is deprecated for Windows 8, Server 2012 and above. You can use schtasks.exe
for same use.
**** UPDATE ****
This the new link of django doc for writing the custom management command
Powershell - Manually trigger a scheduled job
If you run Get-ScheduledJob -id 1 | Get-Member
to retrieve all Members of a Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition
you will see that the object expose a method called StartJob
:
(Get-ScheduledJob -id 1).StartJob()
To retrieve the result, use the Receive-Job cmdlet:
Receive-Job -id 1
How to schedule jobs / tasks
I ended up using JobRunr which I was able to schedule different delays for each task I set up. So far it has been really smoth using it and it has been working out fine for me.
Scheduled annotation in Spring Boot works really fine to but not for me when I wanted to have more flexibility in setting up different delays for each task.
Add a scheduled task at the setup?
There is a Task Scheduler Managed Wrapper on codeplex - this can be used to create a small console application that will setup a task and can be run by your installer.
You can also run the schtasks
command line utility for a similar result.
Registering a scheduled job with PowerShell
you have to use Get-ScheduledJob not get-job
Normaly you can find you jobs in Task Scheduler Library\Microsoft\Windows\PowerShell\Scheduled Jobs.
Look here for more info : http://blogs.technet.com/b/heyscriptingguy/archive/2012/09/18/create-a-powershell-scheduled-job.aspx
and here : http://www.youtube.com/watch?v=RhRoofMOoI0 to see a presentation from PowerShell MVP Jeffery Hicks
Related Topics
Tkinter - Executing Functions Over Time
Flask View Return Error "View Function Did Not Return a Response"
"Inconsistent Use of Tabs and Spaces in Indentation"
How to Fix "Attempted Relative Import in Non-Package" Even With _Init_.Py
How to Download Image Using Requests
Convert All Strings in a List to Int
What's the Difference Between Eval, Exec, and Compile
How to Explicitly Free Memory in Python
How to Define a Two-Dimensional Array
Are For-Loops in Pandas Really Bad? When Should I Care
What's the Difference Between Lists and Tuples