[root@tweb02 ~]# cat rsync5.sh
#!/bin/bash
# chkconfig: 2345 20 80
# description: rsync start and stop scripts
##############################################################
# File Name: rsync5.sh
# Version: V5.0
# Author: junwang
# Created Time : 2018-06-08 17:28:32
# Description:
##############################################################
lockfile=/mnt/rsyncd
rsync_pid=/var/run/rsyncd.pid
. /etc/init.d/functions
start(){
if test -e $lockfile
then
echo "Rsync service started"
exit 6
else
rsync --daemon
retval=$?
if [ $retval -eq 0 ]
then
action "rsync startup ok" /bin/true
touch $lockfile
return $retval
else
action "rsync startup fail" /bin/false
return $retval
fi
fi
}
stop(){
if test -s $rsync_pid
then
rsyncid=`cat $rsync_pid`
if (kill -0 $rsyncid)
then
killall rsync&>/dev/null
retval=$?
if [ $retval -eq 0 ]
then
action "rsync stop ok" /bin/true
rm -f $lockfile
return $retval
else
action "rsync stop fail" /bin/false
return $retval
fi
else
echo "PID does not exist"
return $retval
fi
else
echo "Rsync service did not start"
fi
}
status(){
if test -s $rsync_pid
then
echo "rsync is running"
else
echo "rsync is not running"
fi
}
if [ $# -ne 1 ]
then
echo "usage:$0 {start|stop|restart|status}"
else
case "$1" in
start)
start
retval=$?
;;
stop)
stop
retval=$?
;;
restart)
stop
sleep 1
start
retval=$?
;;
status)
status
retval=$?
;;
*)
echo "usage:$0 {start|stop|restart|status}"
exit 1
esac
exit $retval
fi
rsync 启停脚本
原创
©著作权归作者所有:来自51CTO博客作者旺仔呀旺仔的原创作品,请联系作者获取转载授权,否则将追究法律责任
![](https://ucenter.51cto.com/images/noavatar_middle.gif)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
数据同步--rsync
使用rsync进行两台或多台主机直接的数据同步
rsync数据同步 -
oracle启停脚本
Linx 下oracle 数据库启动停止脚本程序
oracle oracle shell 脚本启动 -
nginx启停脚本
自写,有待改进
nginx shell脚本 case -
hadoop集群启停脚本
hadoop集体启停脚本
hadoop 大数据 hdfs hadoop集群 -
hive 服务启停脚本
hive 服务启停脚本
hive 大数据 hadoop 启动时间 启动服务 -
zookeeper集群启停脚本
zookeeper集群启停脚本
java-zookeeper zookeeper linux hadoop bash -
kafka集群启停脚本
kafka集群启停脚本
kafka linux java hadoop bash