Reputation: 715
My cron runs ok when it's set up like this:
* * * * * usr/local/bin/python3 /Users/username/path/to/my/script1.py
* * * * * bash -c -l "/Users/username//path/to/my/script2.sh"
When I run the above scripts manually in terminal like this, it also works:
usr/local/bin/python3 /Users/username/path/to/my/script1.py
sh /Users/username//path/to/my/script2.sh
However, when I try to run both scripts as a subprocess in a parent.py script scheduled as cron job then it won't work and throw this error:
/bin/sh: usr/local/bin/python3: No such file or directory
My parent.py code:
import subprocess
subprocess.run('usr/local/bin/python3 /Users/username/path/to/my/script1.py && sh /Users/username//path/to/my/script2.sh', shell=True)
however, when I run parent.py manually in terminal like this, it works fine:
usr/local/bin/python3 /Users/username/path/to/my/parent.py
I've tried adding #!/usr/local/bin/python3
to my parent.py but this didn't help.
Could someone help with this? Thanks in advance.
Upvotes: 0
Views: 250