rsync 启动脚本
#!/bin/bash . /etc/init.d/functions pidfile="/var/run/rsyncd.pid" start_rsync="rsync --daemon --config=/etc/rsyncd.conf" status1=$(ps -ef | egrep "rsync --daemon.*rsyncd.conf" | grep -v 'grep') function usage() { echo $"usage:$0 {start|stop|restart}" exit 1 } function start() { sleep 1 if [ "${status1}X" == "X" ];then rm -rf $pidfile ${start_rsync} status2=$(ps -ef | egrep "rsync --daemon.*rsyncd.conf" | grep -v 'grep') if [ "${status2}X" != "X" ];then action "rsyncd is started." /bin/true else action "rsyncd is started." /bin/false fi fi } function stop { killall rsync &> /dev/null rm -rf $pidfile sleep 1 if [ `netstat -anlpe |grep rysnc |wc -l ` -eq 0 ];then action "rsyncd is stoped." /bin/true else action "rsyncd is stoped." /bin/false fi } function status() { if [ "${status1}X" == "X" ];then action "sync is not rununing" else action "syncd is running" fi } function main() { if [ $# -ne 1 ];then usage $0 fi case $1 in start) start ;; stop) stop ;; restart) stop start ;; status) status ;; *) echo echo "Usage: $0 start|stop|restart|status" echo ;; esac } main $*