Best way to automatically restart a process?

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
EdB
Level 3
Level 3
Posts: 107
Joined: Fri Jan 08, 2016 11:34 am

Best way to automatically restart a process?

Post by EdB » Sun Feb 24, 2019 1:56 pm

I want to run x11vnc and make sure it will restart if it fails. Right now, I have it as menu startup process as
x11vnc -forever -nevershared -rfbport xxxxxxx -passwdfile /home/<me>/.vnc/passwd
and that works but it crashed on me when I was remoting in and thus I lost access.
I was thinking about putting it in some sort of bash forever loop but that seems so trashy.

Edit - it appears that there is a flag -loop that mimics an internal forever loop which sounds like it might do what I want.

lordmax
Level 3
Level 3
Posts: 110
Joined: Sun Jun 05, 2011 5:38 am
Location: Turin, Italy
Contact:

Re: Best way to automatically restart a process?

Post by lordmax » Mon Feb 25, 2019 10:45 am

HI,

systemctl has an is-active subcommand for this:

systemctl is-active --quiet service
will exit with status zero if service is active, non-zero otherwise, making it ideal for scripts:

systemctl is-active --quiet service && echo Service is running

Post Reply

Return to “Software & Applications”