In a bash environment:
If your program was not found in the process list it will be started again. It tests every 2 minutes in this example and the loop runs forever (press ctrl-c to break).
Good to run at start up for a robot program, just turn on and it goes!, any errors and it still should run again after 2 minutes.
1 2 3 4 5 6 7 |
#!/bin/bash while true; do ps --no-headers -C sudo python robot.py || sudo python robot.py sleep 2m done |