Reputation: 87
I am new to crontab and I'm struggling with the basics. I a lot of different issues. This is all being done on my Raspberry Pi. I am trying to schedule a python script to run every 10 minutes on weekdays. What makes this trickier is that my python script needs to use a virtual environment.
After doing some research I saw I could just activate the virtual environment with a bash script and then run the python script through that. This is the bash script:
#!/bin/bash
cd /home/pi/Desktop/projects/my_project
source env/bin/activate
python my_script.py
I have no idea if this is the best way to run python in a virtual environment through crontab but its all I could find online. This is the code for the crontab itself:
SHELL=/bin/bash
0-59/10 * * * 1-5 /home/pi/Desktop/projects/my_project/cron_script.sh
I tested the crontab code by running this in the command line: sudo crontab -l | grep -v '^#' | cut -f 6- -d ' ' | while read CMD; do eval $CMD; done
. Again I have no idea if this is the best way to test it immediately. This throws an error message:
bash: /home/pi/Desktop/projects/my_project/cron_script.sh: Permission denied
I'm really just confused at a lot of different steps here. Summary:
Upvotes: 0
Views: 512