Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (51 sloc) 1.013 kb
#!/bin/bash
# http://stackoverflow.com/questions/766397/how-can-i-run-a-perl-script-as-a-system-daemon-in-linux
#
# Source function library.
. /etc/init.d/functions
binary="/home/williamjxj/scraper/baiduD.pl"
[ -x $binary ] || exit 0
RETVAL=0
start() {
echo -n "Starting baidu Daemon: "
daemon $binary
RETVAL=$?
PID=$!
echo
[ $RETVAL -eq 0 ] && touch /var/lock/fmxw/baiduD
echo $PID > /var/run/baiduD.pid
}
stop() {
echo -n "Shutting down baiduD: "
killproc baiduD
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/fmxw/baiduD
rm -f /var/run/baiduD.pid
fi
}
restart() {
echo -n "Restarting baiduD: "
stop
sleep 2
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status baiduD
;;
restart)
restart
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
;;
esac
exit 0
Jump to Line
Something went wrong with that request. Please try again.