I would like to know if there is any simple script to automatically restart a screened background process.
The process gets killed but couldn't manage to create a successful one :(.
Thanks in advance! <3
I would like to know if there is any simple script to automatically restart a screened background process.
The process gets killed but couldn't manage to create a successful one :(.
Thanks in advance! <3
Copyright © 2021 Jogjafile Inc.
I believe that the safest (but not the easiest) way to do this is to create a
cronjob to check if the process is running, and if it is not, restart it again. The reason why this method is "safer", is because if you use a loop like whativanivansuggested and that script "crashes", the program will not be restarted again; on the other hand, by doing viacron, the check program will be called every minute.For example, your
croncould be:The
env DISPLAY=:0might not be needed in your case, or it might be needed, depending on your script (note: you might need to adapt this to your case, runecho $DISPLAYto find out your variable on the case).For example, your
testscriptcould be:On the example above, the
testscriptwould check to see if themainscriptis running (and restart it if necessary) twice every minute.