Skip to content Skip to sidebar Skip to footer

Cron Not Launching A Working Python Script

I have more than some troubles getting cron working on my raspberry pi 3b. I wrote a python script and I have no issues launching it from thonny or terminal, it runs smoothly. Howe

Solution 1:

If you are running a virtual environment your paths in a shell script need to be for that virtual environment. Here's how I run shell on AWS linux instance. You can play around with this but it took me a while to figure it out. Maybe just add the long environment path in cron and skip the shell script.

This is inside my_shell.sh

/usr/local/bin/pipenv run ~/.local/share/virtualenvs/ec2-user-zzkNbF-x/bin/python /home/ec2-user/my_path_to_file/my_file.py

This is my crontab setting

0 21 * * mon-fri /home/ec2-user/my_path_to_file/my_shell.sh

Post a Comment for "Cron Not Launching A Working Python Script"