I'm trying to run a Python script which needs to be executed with virtualenv activated with cron
Based on this Cron and virtualenv thread I've come up with this:
SHELL=/bin/bash
0 * * * * export FLASK_APP=/home/mark/off_web/project/__init__.py
1 * * * * export FLASK_ENV=development
*/10 * * * * root source /home/mark/off_web/venv/bin/activate && /usr/bin/python3 /home/mark/web_off/deletion.py
After editing I can see output crontab: installing new crontab
but then I take a look if
the script has been executed and can see that it hasn't. Does crontab: installing new crontab
also mean that it's triggering new execution ? * * * *
means that it will be ran every day.
Edit:
edited crontab to look like:
0 * * * * /home/mark/off_web/kick_off_deletion_script.sh
kick_off_deletion_script:
#!/bin/sh
export FLASK_APP=/home/mark/off_web/project/__init__.py
export FLASK_ENV=development
. /home/mark/off_web/venv/bin/activate
/usr/bin/python3 deletion.py
echo "Executed"
after running the shell script I get ModuleNotFoundError: No module named 'flask'
despite it being installed.