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