The get_pid() function below is intended to return the PID of daemon_itinerary.sh.
The script below is not in the same working directory as daemon_itinerary.sh.
#!/bin/bash
PID=""
get_pid() {
PID='pidof daemon_itinerary.sh'
}
start() {
echo "Restarting test_daemon"
get_pid
if [[ -z $PID ]]; then
echo "starting test_daemon .."
sh /var/www/bin/daemon_itinerary.sh &
get_pid
echo "done. PID=$PID"
else
echo "test_deamon is alrady running, PID=$PID"
fi
}
case "$1" in
start)
start
;;
...
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
*edit
Start is being passed in as a command line argument.