benbot/bot

41 lines
910 B
Plaintext
Raw Normal View History

2017-03-13 23:31:15 +00:00
#!/bin/bash
pid=$(ps -ef | grep bot.php | grep -v grep | awk '{print $2}')
case "$1" in
start)
if [ "" == "$pid" ]; then
nohup php bot.php > bot.out &
else
echo "bot already running"
fi
;;
stop)
if [ "" != "$pid" ]; then
echo "killing bot ($pid)"
kill $pid
fi
;;
status)
if [ "" != "$pid" ]; then
echo "bot running with pid $pid"
else
echo "bot not running"
fi
;;
restart)
if [ "" != "$pid" ]; then
echo "killing bot ($pid)"
kill $pid
fi
nohup php bot.php > bot.out &
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac