创建Linux服务

Tomcat
1.创建脚本    
    脚本中chkconfig后面的2345表示Linux启动等级,10和90表示开机启动和关机停止的优先级,数值越小,触发越早
#! /bin/bash #chkconfig:2345 10 90 #description:Start or Stop Tomcat Service case $1 in start) echo "Starting Tomcat Service" su - lihuilin -c "/software/apache-tomcat-7.0.47/bin/catalina.sh start">>/dev/null ;; stop) echo "Stoping Tomcat Service" su - lihuilin -c "/software/apache-tomcat-7.0.47/bin/catalina.sh stop">>/dev/null ;; restart) echo "Restarting Tomcat Service" su - lihuilin -c "/software/apache-tomcat-7.0.47/bin/catalina.sh stop">>/dev/null su - lihuilin -c "/software/apache-tomcat-7.0.47/bin/catalina.sh start">>/dev/null ;; *) echo $"Usage: tomcat {start|stop|restart}" esac
2.添加服务
    将脚本移动至/etc/init.d/目录下,将其添加为服务

[root@lihuilin init.d]# chkconfig --add tomcat [root@lihuilin init.d]# chkconfig tomcat on [root@lihuilin init.d]# service tomcat start

Oracle
1.修改/etc/oratab
    将oratab的内容orcl:/software/app/lihuilin/product/11.2.0/dbhome_1:N
    改为orcl:/software/app/lihuilin/product/11.2.0/dbhome_1:Y
    这样Oracle的dbstart和dbshut命令就可以使用了。    
    需要修改日志的读写权限
2.创建脚本和服务
    
#!/bin/bash #chkconfig:2345 10 90 #description:Start or Stop Oracle Service case $1 in start) echo "Starting Oracle Service" su - lihuilin -c "/software/app/lihuilin/product/11.2.0/dbhome_1/bin/lsnrctl start">>/dev/null su - lihuilin -c "/software/app/lihuilin/product/11.2.0/dbhome_1/bin/dbstart">>/dev/null ;; stop) echo "Stoping Oracle Service" su - lihuilin -c "/software/app/lihuilin/product/11.2.0/dbhome_1/bin/lsnrctl stop">>/dev/null su - lihuilin -c "/software/app/lihuilin/product/11.2.0/dbhome_1/bin/dbshut">>/dev/null ;; *) echo $"Usage: oracle {start|stop}" esac




    

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29254281/viewspace-1063036/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29254281/viewspace-1063036/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值