0

I tried using crontab but didn’t work. Also, do I need a nohup to keep it running after exit the SSH connection?

02 19 * * * /usr/bin python3.7 myScript.py
3

You have a couple of syntax errors there. First, if you want to run myScript.py with python3.7 which is in /usr/bin, then you need:

/usr/bin/python3.7 myScript.py

Next, you need to give the full path to the script. So if the script is in your home directory, use (change /home/marcelo/ to your actual home directory):

02 19 * * * /usr/bin/python3.7 /home/marcelo/myScript.py

And no, you don't need nohup or anything else. This won't be connected to your ssh session in any way.

Finally, it is more common to use shebangs for this sort of thing. Just add this line as the first line of your script:

#!/usr/bin/python3.7

Then, make it executable (chmod +x /home/marcelo/myScript.py) and you can run your script directly:

02 19 * * * /home/marcelo/myScript.py
  • thank you very much! the error was: my python is installed at /usr/local/bin/python3.7 – Marcelo Gazzola Jun 10 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.