linux rsync启动脚本,linux系统服务rsync启动脚本

本脚本估计存在一些问题:如有发现,请告知谢谢~#!/bin/sh

# chkconfig: 2345 21 60

# description: Saves and restores system entropy pool for \

#create by xiaohu

#2014.06.02

#This script is the Rsync service script

. /etc/init.d/functions

case "$1" in

start)

echo "rsync is starting"

rsync --daemon

sleep 2

myport=`netstat -lnt|grep 873|wc -l`

if [ $myport -eq 2 ]

then

action "rsync start"   /bin/true

else

action "rsync start"   /bin/false

fi

;;

stop)

echo "rsync is stoping"

myport=`netstat -lnt|grep 873|wc -l`

if [ $myport -eq 2 ]

then

killall rsync &>/dev/null

sleep 2

killall rsync &>/dev/null

sleep 1

fi

myport=`netstat -lnt|grep 873|wc -l`

if [ $myport -ne 2 ]

then

action "rsync stop"   /bin/true

else

action "rsync stop"   /bin/false

fi

;;

restart)

if [ `netstat -lnt|grep 873|wc -l` -eq 0 ]

then

rsync --daemon

sleep 2

myport=`netstat -lnt|grep 873|wc -l`

if [ $myport -eq 2 ]

then

action "rsync restart"   /bin/true

else

action "rsync restart"   /bin/false

exit

fi

else

killall rsync &>/dev/null

sleep 2

killall rsync &>/dev/null

sleep 1

rsync --daemon

sleep 2

myport=`netstat -lnt|grep 873|wc -l`

if [ $myport -eq 2 ]

then

action "rsync restart"   /bin/true

else

action "rsync restart"   /bin/false

fi

fi

;;

status)

myport=`netstat -lnt|grep 873|wc -l`

if [ $myport -eq 2 ]

then

echo  "rsync is running"

else

echo "rsync is stoped"

fi

;;

*)

echo $"Usage: $0 {start|stop|status|restart}"

;;

esac

在stop参数中,不建议采用pkill或看kill,尤其是数据库方面,容易让服务出现问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值