Re: Making sure one and only one copy of a process is always running

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2003-11-03 at 05:06, Ian Mortimer wrote:
> >     * checks to see if it is running and restarts itself if the previous 
> > instance died
> >     * never runs two copies of itself
> > 
> > I have read through the files in /etc/rc.d/init.d for hints, since I know 
> > that somehow they put the PID in a file and then check that file to see if 
> > it's running or not. Duplicating this functionality is one possibility.

i have a simple bash daemon that launches at startup, and repeatedly via
cron in case it for some reason dies or hangs.  inside it here and
there, after things that can take noticable time, before doing things
where concurrency would be bad, i stick calls to a function that checks
to see if the current instance is the most recently launched (= saved
pid?), otherwise voluntarily die.

of course if you want you can decide to give precedence to the earlier
started instance, but that leads to more thorny semaphore issues so i
avoided that.


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux