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
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
You have a couple of syntax errors there. First, if you want to run
python3.7 which is in
/usr/bin, then you need:
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:
Then, make it executable (
chmod +x /home/marcelo/myScript.py) and you can run your script directly:
02 19 * * * /home/marcelo/myScript.py