pythondjangocrondjango-cron

Django crontab is not working in background


I am using django-crontab to run some cron jobs as part of my project. I have a virtual environment setup for this particular project.

So after activating the environment, I add the jobs by using the following command :

python manage.py crontab add

I see that my jobs are succcessfully added to the OS crontab, however when I see the logs, I found that it was not able to find certain modules(read all) that were installed in virtual environment.

However if I run those crons manually by passing the hash to the run command it runs successfully.

On further inspection I found when the crons are added to the crontab, the python binaries are pointed to the global(system level binaries) instead of the virtual level binaries.

The only solution I can think of is to run pip install at a system level but that will mess up the sanbox environment I intend to create.

Any ideas?


Solution

  • django-crontab is not maintained anymore. Last changes to this library happened over 2 years ago. I really advise stopping using it.

    For fixing that bug, you can use either CRONTAB_PYTHON_EXECUTABLE setting to point to python executable from your env, or CRONTAB_COMMAND_PREFIX to add something that will just activate this virtualenv before running python.