Case5:Rsync网络服务启动脚本--通过pid file文件判断

18 篇文章 4 订阅 ¥29.90 ¥99.00
本文介绍了如何建立Rsync网络服务的启动脚本,包括通过PID文件判断进程状态,编写启动脚本,以及设置开机启动和管理。具体步骤包括创建配置文件,查看并获取PID,编写启动脚本,并使用chkconfig将其设为开机启动。
摘要由CSDN通过智能技术生成

1 建立文件,模拟启动(端口873)
touch /etc/rsyncd.conf
rsync --daemon

2 查看pid file,通过pid进程停止rsync
cat /etc/rsyncd.conf
打开pid file
pid file=/var/run/rsyncd.pid
获取pid进程号
cat /var/run/rsyncd.pid 

3 编写脚本内容

#!/bin/bash
# chkconfig: 2345 22 61
# description: start rsync and stop rsync scripts.
. /etc/init.d/functions
pidfile="/var/run/rsyncd.pid"
start_rsync(){
if [ -f $pidfile ] 
  then
     echo "rsync is runnning"
else
   rsync --daemon
   action "rsync is started" /bin/true
fi
}
stop_rsync(){
if [ -f $pidfile ]
  then
    kill -USR2 `cat $pidfile`
    rm -f ${pidfile}
    action "rsync is stopped" /bin/true
else
    acti
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值