好记性不如烂笔头,此篇是为了方便以后速查关于防火墙Iptables的命令。

将某个程序命令注册成service,举例tomcat

1
vi /etc/init.d/tomcat

添加脚本内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# description: Tomcat7 Start Stop Restart
# processname: tomcat7
# chkconfig: 234 20 80

CATALINA_HOME=/usr/local/tomcat/apache-tomcat-7.0.77

case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
*)
echo 'please use : tomcat {start | stop | restart}'
;;
esac
exit 0

保存shell脚本

1
2
3
4
5
serrvice tomcat start    #启动

service tomcat stop #停止

service tomcat restart #重启