#!/bin/bash
PID=$(pidof daemon)
kill $PID
while ps -e | grep "[d]aemon" >> /dev/null;
do
sleep 30
done
sh -c /root/daemon
This script is set on a cronjob to kill and restart this program. It does that but then after the script should exit, it keeps respawning, making it very difficult to keep the daemon manually. It should restart the program in a subshell and the script should die.