I am trying to run a python script on Linux via WSL.
First of all I run
service --status-all and both
cron are marked as
[+]. Just to make sure that it works i typed in
crontab -e the following:
*/2 * * * * /home/myname/Task_scripts/example.sh
This is what the script file example.sh looks like:
#!/bin/sh echo "Hello World - Generated every 2 mins" >> ~/hello1.txt
The file indeed runs as set every 2mins so everything fine so far.
Let's move to the Python part now. I follow the exact same process i.e. crontab with a script and cannot get it run no matter what. In specific these are the two alternatives (among the many i tried) that i expected to work but apparently do not. FYI I am using an anaconda environment.
What i have in crontab:
*/2 * * * * /home/myname/Task_scripts/email_example.sh
How the file looks like:
#!/bin/sh /home/myname/anaconda3/envs/py36env/bin/python /home/myname/Production/example_email.py
Here are the rights in the .py file after running
chmod +x email_example.sh:
-rwxrwxrwx 1 myname myname 99 Nov 7 21:26 email_example.sh
Set the crontab as follows:
*/2 * * * * /home/myname/anaconda3/envs/py36env/bin/python /home/myname/Production/example_email.py
The rights on the .py are same as above.
Executing manually the:
runs as it is supposed to do.