Tivix/django-cron

using django-cron service autorun is possible in windows10

xporium opened this issue · 4 comments

Hi,

i followed the demo steps, but when i run command like 'python manage.py runcrons' than service run and print something.

Now i want to print something in every 1 minute than i have to run above command every minute?

is auto run possible?

actually i used crontab but in windows 10 it gives me

"adding cronjob: (f69148c03234fcfa3ae847753e06aa40) -> ('*/1 * * * *', 'test_app.cron.my_scheduled_job')
The system cannot find the path specified." error.

So how to make it autorun service in my project?

thanks

Windows does not have a crontab. You can use the task scheduler and set up a job to run every min to call the command.

Sorry for not responding sooner, I have been busy. Here is how I have the task scheduler set up:

First, go to start, and search for Task Scheduler. On the right Actions panel, click Create Task....

In the General tab, you can set up things as needed. For a simple set up, you can leave everything with the defaults. For our production needs, we have it running under a different cron account we created and checked Run whether user is logged on or not and Run with highest privileges. I am not sure if Run with highest privileges is actually needed.

In the Triggers tab, click New... and set the date and time you want this to start. Check the box to Repeat task every: and type in 1 minute in the combo box. Set the duration to Indefinitely. Make sure Enabled is checked.

In the Actions tab, click New.... Have the Action set to Start a program. Program/script should be the full path to your python.exe (ideally within a virtual environment e.g. C:\django\project\root\.venv\Scripts\python.exe)
Add arguments (optional) should be the full path to manage.py and runcrons (e.g. C:\django\project\root\manage.py runcrons
Start in can be blank, but I find it is better to also have this set to the django root path.

Everything within the Settings tab can be left as is. The only setting I have changed is the last drop down. We changed it to Run a new instance in parallel. This way if we have a long running job, it does not stop the other jobs from running until the 1 job finishes.

Also note, Windows Task Scheduler will not always run your jobs on time. I find that sometimes Windows just does not start the jobs on time. We are still debugging this to find out why.

Use 'python manage.py cronloop' instead of 'python manage.py runcrons'