It's alive! Well sorta.

Olli Ries olli at
Sat Dec 7 07:45:58 MST 2013

On Sat, Dec 7, 2013 at 7:43 AM, Olli Ries <olli at> wrote:

> On Sat, Dec 7, 2013 at 2:18 AM, S. Dale Morrey <sdalemorrey at>wrote:
>> I've got a system I'm in charge of that uses a standard init script. i.e.
>> /etc/init.d/mydeamon start
>> The problem is the daemon can randomly crash and because it's a signed
>> binary I can't just fix the problem and recompile.
>> The thing MUST stay running.  I was thinking about using a Nagios solution
>> but that seems like overkill.
>> Is there someway to check if the process is running with cron?  I was
>> thinking I could just do a restart once an hour, but it seems there should
>> just be a way to check the pid to see if it's running instead of a full
>> restart.
> why not write the PID in the start script to some file and then either
> check via ps afx | grep $PID or kill -0 $PID and then restart, plus some
> logic to detect stale PID files etc. However, there is a likely race
> condition where when the process dies the PID can be reused by a different
> parent (which I believe happens in a round robin
> after /proc/sys/kernel/pid_max is exhausted). Matching process name & PID
> is a safe guard in that case.

to be clear, ps afx | grep & kill -0 would be run in a cron job


More information about the PLUG mailing list