Sunday, 6 April 2014

fsniper init script on Centos

Create a file name  "fsniper"  and add below content

[root@fsniper-1.3.1] vim /etc/init.d/fsniper


export HOME=/root

case "$1" in
start)
echo -n "Starting Fsniper: "
/usr/local/bin/fsniper --daemon
echo -e "... [ \e[00;32mOK\e[00m ]"
;;
stop)
echo -n "Shutdown Fsniper: "
kill -9 `ps aux | grep "fsniper --daemon" | grep -v grep | awk {'print $2'}`
echo -e "... [ \e[00;32mOK\e[00m ]"
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart"
exit 1
esac

exit 0

that's it, save and exit.

use below command to set execute permission for /etc/init.d/fsniper file

[root@fsniper-1.3.1] chmod +x /etc/init.d/fsniper


Start the fsniper service using below command

[root@fsniper-1.3.1] service fsniper start

or

[root@fsniper-1.3.1] /etc/init.d/fsniper start

After started the fsniper, we can check the fsniper process whether running or not

[root@fsniper-1.3.1] ps -aux | grep fsniper

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      2788  0.0  0.0  13588  1412 ?        S    Jul19   0:00 /usr/local/bin/fsniper --daemon
root     17060  0.0  0.0 103248   896 pts/2    S+   20:20   0:00 grep fsniper

[root@fsniper-1.3.1] 

No comments:

Post a Comment