Mark Anthony Libres
Mark Anthony Libres

Reputation: 1074

Django, how to run a command through Windows Task Scheduler

How to schedule and run a specific command in django using Windows Task Scheduler. My django project is not currently local server deployed but using the manual set up just like activating the virtual environment and then typing the python manage.py runserver on terminal rather deploying through xampp or laragon. But i am bit confused on how to achieve to schedule and run a command like python manage py get_source through the use of Windows Task Scheduler.

Upvotes: 1

Views: 958

Answers (2)

David Weber
David Weber

Reputation: 63

I had the same problem.

The main issue is, that you missed the full path to python.exe as an execution application. "Python" will not work.

And then your application as an argument. Additionally, to that, you can add w to py. This will make it runnable on windows without a .bat file.

Application to execute:

C:\user\python.exe Argument: manage.pyw runserver

Upvotes: 0

kjarsenal
kjarsenal

Reputation: 934

Don't know if you're still looking for this but I found a working solution here - configure .bat file to run commands in Django Virtual Env Very simple; point to the location of your project directory...

cd C:\webapps\my-project-dir-with-manage.py-inside

copy and paste the contents of the system generated activate.bat,found inside your venv/Scripts folder...

add your command line...

.\manage.py <your command here>

save as myfile.bat, and schedule via the Windows Task Scheduler. Super simple.

Upvotes: 1

Related Questions