您好,登錄后才能下訂單哦!
#!/bin/sh
#filename:rsync_start.sh
#date:2015-12-14
#作者:linuxzkq
#version:v1.0
# chkconfig: 2345 23 65
# description: Start rsync and stop rsync scripts.
prog="rsync"
pidfile=/var/run/rsyncd.pid
exec=/usr/bin/rsync
. /etc/init.d/functions
[ -f /usr/bin/rsync ] || echo "please install and config rsync!"
#USAGE
function USAGE(){
echo "USAGE:$0 {start|stop|restart}"
exit 1
}
#start
function start(){
$exec --daemon >/dev/null 2>&1
if [ -s "$pidfile" ]
then
action "rsync haved already been running" /bin/false
else
$exec --daemon >/dev/null 2>&1
action "start rsyncd:" /bin/true
fi
}
#stop
function stop(){
if [ -f "$pidfile" ]
then
kill -USR2 `cat $pidfile`
rm -f ${pidfile}
action "stop rsyncd:" /bin/true
else
action "rsync no running!" /bin/false
fi
}
case "$1" in
start) start
RETVAL=$?
;;
stop) stop
RETVAL=$?
;;
restart) stop && sleep 2 && start
RETVAL=$?
;;
*) echo "Error,Please use an USAGE!"
USAGE
esac
exit $RETVAL
歡迎各位網友拍磚,老鳥及高手指正!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。