This Bash script may be executed on a terminal or by a task scheduler such as cron and it does the following:
- Execute ps to print a snapshot of the current processes;
- Match the print with grep to see if the argument supplied is found in the current processes; and
- If the argument supplied is not found, execute it.
A detailed walk-through is available here.
Get started in three simple steps:
- Download a copy of the script;
- Provide the script with execute permission; and
- Run the script.
Download a copy of the script with git clone
.
$ git clone https://github.com/kurtcms/daemonc /app/daemonc/
Provide the script with execute permission.
$ chmod +x /app/daemonc/daemonc.sh
Run the script with an executable process and its corresponding argument(s) as arguments(s).
$ /app/daemonc/daemonc.sh iperf -s -D
And have the output of the supplied executable process returned, or have nothing returned if it is found in the current processes.
Running Iperf Server as a daemon