Linux service 创建和注册
2016-05-19 17:47
423 查看
1. 创建
[root@c4t22927 init.d]# pwd
/etc/rc.d/init.d
[root@c4t22927 init.d]# vim tian
# start function
start() {
echo "=== tian startService ==="
sleep 2
}
#stop function
stop() {
echo "=== tian stopService ==="
}
#stop function
status() {
echo "=== tian status Service ==="
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload|restart)
stop
start
;;
status)
status $SNAME
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
2. 注册
chkconfig --add tian
3.开机启动
chkconfig --level 35 tian on
3. 验证
[root@c4t22927 init.d]# service tian restart
=== tian stopService ===
=== tian startService ===
[root@c4t22927 init.d]# service tian status
=== tian status Service ===
[root@c4t22927 init.d]#
[root@c4t22927 init.d]# pwd
/etc/rc.d/init.d
[root@c4t22927 init.d]# vim tian
# start function
start() {
echo "=== tian startService ==="
sleep 2
}
#stop function
stop() {
echo "=== tian stopService ==="
}
#stop function
status() {
echo "=== tian status Service ==="
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload|restart)
stop
start
;;
status)
status $SNAME
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
2. 注册
chkconfig --add tian
3.开机启动
chkconfig --level 35 tian on
3. 验证
[root@c4t22927 init.d]# service tian restart
=== tian stopService ===
=== tian startService ===
[root@c4t22927 init.d]# service tian status
=== tian status Service ===
[root@c4t22927 init.d]#
相关文章推荐
- Hello World_Linux篇——测试gcc和g++是否可用
- centos6.7升级svn1.6到1.8
- Centos7 PostgreSQL安装
- 《Linux驱动》分层分离
- linux内核启动第二阶段分析-setup_arch()函数
- 20160518:Linux系统搭建NFS并共享给AIX
- centos6安装elasticsearch-2.3.3
- 《Linux驱动》输入子系统
- arm-linux驱动:c文件操作控制驱动
- 迁移与裁剪linux系统
- CentOS/RHEL 7中的firewall控制
- LINUX iptables
- Linux运维人员如何学习python编程
- SecureCRT ssh登录linux 显示connection closed
- linux使用小记
- linux 下问题处理
- Linux系统位数查看方法
- pwd,cd,type
- centos6.7环境之kvm虚拟化quem工具配置及使用详解
- centos6.7环境之kvm虚拟化quem工具配置及使用详解