Django crontab not executing test function
Your code actually works. You may be think that print("Hello")
should appear in stdout? So it doesn't work that way, because cron doesn't use stdour
and stderr
for it's output. To see actual results you should point path to some log file in CRONJOBS
list: just put '>> /path/to/log/file.log'
as last argument, e.g:
CRONJOBS = [
('*/1 * * * *', 'media_api_server.cron.cronSendEmail', '>> /path/to/log/file.log')
]
Also it might be helpful to redirect your errors to stdout too. For this you heed to add CRONTAB_COMMAND_SUFFIX = '2>&1'
to your settings.py
source
sometimes not working in shell scripts
use .
(dot) instead
*/1 * * * * . /home/app/env/bin/activate e.t.c.