I have a program that should run all the time (it collects some statistics) after Xorg start. However, there can occur some exceptions in this program, or it can be unintentionally closed, and what I want is to automatically restart it. The first idea is to run every minute another script with cron, which will restart it, but this doesn't seem optimal, so what's the preferred method of doing this?
There are many ways of doing this and which one you choose depends on how the script is being run. An easy way that works for any command and does not require root access is to run something like this:
This will run for ever (