crontool
Paste a schedule, read it in English, see the next runs.

Running a Django Command with Cron

Call the virtualenv's python directly with the full path to manage.py, and set DJANGO_SETTINGS_MODULE if your project needs it. This runs any management command — clearsessions, custom commands, data imports — on schedule.

The crontab line

30 3 * * * /opt/app/venv/bin/python /opt/app/manage.py clearsessions >> /var/log/django-cron.log 2>&1

Using the venv's python directly means you don't need to activate the environment — it already points at the right interpreter and packages.

Set the settings module

If your command needs it: 30 3 * * * DJANGO_SETTINGS_MODULE=app.settings.prod /opt/app/venv/bin/python /opt/app/manage.py my_command

Custom management commands

Any command in app/management/commands/ works the same way — swap clearsessions for your command name.

FAQ

How do I run a Django management command in cron?

Call the virtualenv python with the full path: 30 3 * * * /opt/app/venv/bin/python /opt/app/manage.py clearsessions.

Do I need to activate the virtualenv in cron?

No. Point cron at venv/bin/python directly; it uses the correct interpreter and installed packages without activation.

How do I set DJANGO_SETTINGS_MODULE in cron?

Prefix the command: DJANGO_SETTINGS_MODULE=app.settings.prod before the python call, or set it at the top of the crontab.