> Hello, all: > > I am trying to create a job which will run for a long time, so I need to > make sure that it: > > * starts up automatically > > * is always running > > * 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 am running a shell script that runs an rsync process, so perhaps even > something as simple as checking the exit status of rsync with a while loop > inside the script would work. However, I don't know how to do that, and my > reading of the bash man page has not provided enough enlightenment. > > Anyone care to offer suggestions? Create a script called run_application_ like this: #!/bin/sh while : do _application_ sleep 10 done (Replace _application_ with the name of the application). Then in /etc/rc.d/init.d create a startup script that calls the run_application_ script and make links in the required runlevels. That will start the job and if it dies wait 10 seconds and start it again. You could add some features: logging starts and stops keep a count of stops and starts and if it fails too often break out of the loop and mail a warning keep a count of stops and starts and if it fails too frequently in a short space of time break out of the loop and mail a warning -- Ian -- redhat-list mailing list unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe https://www.redhat.com/mailman/listinfo/redhat-list