启动rsync服务的脚本并能用chkconfig管理
来源:互联网 发布:java复试 编辑:程序博客网 时间:2024/06/05 12:48
1. 创建脚本
# Description: #!/bin/bash# chkconfig: 2345 31 61 # 设置chkconfig 级别# description: start or stop rsync daemon # 描述 . /etc/init.d/functionspidfile=/var/run/rsyncd.pidRETVAL=0start_rsync(){if [ -f $pidfile ];then # 判断pid文件,存在就不再启动 echo "Rsync is already running"else rsync --daemon action "Rsync starts successfully " /bin/truefi }stop_rsync(){if [ -f $pidfile ];then kill -USR2 `cat $pidfile` rm -rf $pidfile # 停止服务,就删除pid文件 action "Rsync stops successfully" /bin/trueelse action "Rsync is already stopped.Stop Failed" /bin/false fi}case "$1" in start) start_rsync RETVAL=$? ;; stop) stop_rsync RETVAL=$? ;; restart) stop_rsync sleep 2 start_rsync RETVAL=$? ;; *) echo "Usage:$0 start|stop|restart" exit 1 esacexit $RETVAL
2. 脚本前端加入
# chkconfig: 2345 31 61# description: start or stop rsync daemon
3. 拷贝到/etc/init.d目录
cp rsync.sh /etc/init.d/rsyncdcd /etc/init.dchmod +x rsyncd
4. 加入chkconfig
chkconfig --add rsyncdchkconfig --list rsyncdsyncd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
5. 启动服务
service rsyncd start #因为是根据/var/run/rsyncd.pid是否存在判断进程是否开启,第一次启动时确保没有该pid文件
0 0
- 启动rsync服务的脚本并能用chkconfig管理
- php-fpm服务启动脚本 service chkconfig
- nginx 服务启动脚本 chkconfig service
- 开机启动服务chkconfig开机启动脚本/etc/rc.local
- 用红帽子的chkconfig管理Init脚本
- 用红帽子的chkconfig管理Init脚本
- centos下nginx启动脚本和chkconfig管理
- linux的chkconfig服务注册(服务注册脚本说明)
- 服务不支持chkconfig解决方法脚本
- 服务不支持chkconfig解决方法脚本
- linux下自启动服务的管理及chkconfig的应用(ubuntu 和 RedHat为例)
- rsync启动脚本
- rsync启动脚本
- rsync启动脚本
- chkconfig 开机启动服务命令
- linux 启动脚本以及解决chkconfig的办法
- 使用chkconfig (sysv-rc-conf)实现脚本的自启动
- (转)用红帽子的 chkconfig 管理 Init 脚本
- RAC挂载共享磁盘组
- jquery常用事件
- mysql处理海量数据时的一些优化查询速度方法
- LoadRunner使用笔记
- hdu1020
- 启动rsync服务的脚本并能用chkconfig管理
- 父类方法中使用this,那么这个this指的是谁?
- DataNode数据处理中心DataXceiver
- 国外那些优秀的 Drupal 教程博客
- 高质量C++/C编程指南(一)
- WC2016随记
- CSDN ios app体验怎么这么差啊,求推荐好用的app
- python packaging
- 多线程模拟实现生产者/消费者模型