XXX XXX WARNING: old character encoding and/or character set XXX KEEP-RUNNING(1.06) KEEP-RUNNING(1.06) NAME keep-running - respawn a process continuously SYNOPSIS keep-running [-m mail-address] [-t template] [-r retries] [-d max- delay] [-S command ] [-u username] [-c watch-file] [-l log-target] [-D] [-L lock-file] [-C] command args ... DESCRIPTION keep-running will spawn command, and respawn it if it dies. It will optionally send e-mail when this happens. If command dies again immediately, wait a while before retrying. The wait doubles for each attempt, but keep-running will check the binary of command for changes every five seconds and try to respawn it immediately if it has changed (see also -c). If the number of retries is exceeded, keep-running will exit. Whenever the command runs successfully, the retry counter and retry interval is reset. A "successful run" is defined to be a run lasting more than a minute. OPTIONS -r retries How many consecutive unsuccessful attempts of running the service to allow before giving up. The default is infinite. -d maxdelay The delay doubles for each attempt until it reaches this value. The value is specified in seconds, but some common suffixes are understood: w(eek), d(ay), h(our), m(inute) and s(econd). They can be combined, like "1h30m". The default is "1d". -u username This option requires superuser priveleges. During startup, keep-running will give up its root access and switch to username. -S command When keep-running receives SIGINT or SIGTERM, it will run command to shut down the service it is watching. If no service is currently running, command will not be run. If no command has been specified, or command returns a non-zero exit code, keep-running will send the same signal it received to its running child. -m mail-address Send report to mail-address whenever the command dies. keep- running includes its own simple MTA engine, so a working e-mail configuration on the host is not needed. -t template The template message to use for the e-mail report. The following keywords, enclosed in ${}, are replaced: USERNAME The name of the user running the service. HOSTNAME The name of the host where the service is running. SHORT_HOSTNAME The first component of the hostname. RECIPIENT The address given as parameter to -m. PROGRAM The program keep-running is monitoring. ARGUMENTS The arguments given to the program. STATUS The exit status of the program. SIGNAL The numeric value of the signal which terminated the program, or "0" the program exited normally. DURATION How long the program had been running before it was restarted. -l log-target If log-target contains a slash, log to the specified file rather than standard error. Otherwise, try to use the value as a syslog(3) facility name. -c watch-file While waiting to respawn the service, periodically check whether watch-file has changed, and if so, try again immediately. The actual contents of the file are ignored. Useful when the most common reason for the service dying is a faulty configuration file. More than one -c option can be given. -D Run as a daemon in the background. Requires -l. -L lock-file Only run if an exclusive lock can be held on lock-file. The PID of keep-running is written to this file. -C Exit silently if keep-running is already running. Requires -L. EXAMPLES keep-running -m pager@example.com /usr/sbin/exim -bdf keep-running -l LOCAL2 /usr/bin/mozilla kiosk.html Launching from cron: * * * * * keep-running -l LOCAL2 -CDL /var/lock/my.lock my-command SIGNALS SIGHUP If keep-running is waiting to respawn the process, SIGHUP will trigger a new attempt immediately. Under other circumstances, SIGHUP is ignored. BUGS A zombie from the e-mail delivery may be left hanging around until the watched process terminates. AUTHOR Send bug reports or feature requests to Kjetil T. Homme 16 May 2008 KEEP-RUNNING(1.06)