Startup scripts samples.
THIS DOES NOT QUITE WORK! The job starts but the pid is not the real pid! So the stop is also bad because of this.
#!/bin/bash RUN_FILE=/var/run/somejob.pid nohup some-job > /dev/null 2>&1 & echo $! >> $RUN_FILE exit
THIS DOES NOT QUITE WORK!
#!/bin/bash RUN_FILE=/var/run/somejob.pid for pids in `cat $RUN_FILE`; do echo "Killing: $pids" kill -9 $pids done
#!/bin/bash /path/to/stop-job.bash #sleep 5 /path/to/start-job.bash
#!/bin/bash HAPCOUNT=`pgrep haproxy|wc -l` if [ $HAPCOUNT -eq 0 ] then echo "Starting haproxy ..." haproxy -f /etc/haproxy/haproxy.cfg else echo "haproxy already running" fi exit
#!/bin/bash HAPCOUNT=`pgrep haproxy|wc -l` if [ $HAPCOUNT -eq 0 ] then echo "haproxy not running" exit fi # for pids in `pgrep haproxy`; do echo "Killing: $pids" kill -9 $pids done exit