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
action "rsync have already been stopped" /bin/fasle
fi
}
case "$1" in
start)
start_
本文介绍了如何创建并管理Rsync网络服务的启动脚本,包括通过PID文件判断服务状态、停止和重启服务,以及设置开机启动。步骤涉及编辑rsyncd.conf配置文件,设置PID文件,编写启动脚本rsyncd.sh,并将其添加到系统初始化服务中。
订阅专栏 解锁全文
344

被折叠的 条评论
为什么被折叠?



