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
cron
job 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 whativanivan
suggested 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
cron
could be:The
env DISPLAY=:0
might 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 $DISPLAY
to find out your variable on the case).For example, your
testscript
could be:On the example above, the
testscript
would check to see if themainscript
is running (and restart it if necessary) twice every minute.