I have a python script, and i'd like to make it run every 10 minutes, how can i do this? Thanks in advance.
Make the script executable by:
chmod u+x /path/to/script.py
Note that, you need a shebang (i.e. indicate interpreter in the first line of the script), for
Open your cron table by
Add the following
*/10 * * * * /path/to/script.py
Note that, if the script is not executable you can indicate the interpreter on the go:
*/10 * * * * /usr/bin/env python2 /path/to/script.py
*/10 * * * * /usr/bin/env python3 /path/to/script.py
cron, you could also call your script in an infinite loop with a delay of 10 minutes.
If you want to launch the script again 10 minutes after the previous instance exited, use this:
while true ; do /PATH/TO/SCRIPT.PY ; sleep 10m ; done
However, if you want to launch the script every 10 minutes on the clock, no matter how long the last instance was running (or whether it still is running), you must execute the script in background and sleep in parallel by replacing the
; with an
while true ; do /PATH/TO/SCRIPT.PY & sleep 10m ; done