1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/bin/bash
#chkconfig: 2345 30 50
#Date:2017-6-29
#Author:xcn(baishuchao@yeah.net)
#version 1.0
PID=
"/var/run/rsync.pid"
start_rsync(){
if
[ -f $PID ]
then
echo
"rsync is running"
else
rsync
--daemon
echo
"rsync is started"
fi
}
stop_rsync(){
if
[ -f $PID ]
#存在而不为空
then
kill
-USR2 `
cat
$PID`
rm
-rf $PID
echo
"rsync is stoped"
else
echo
"rsync no running"
fi
}
case
$1
in
start)
start_rsync
;;
stop)
stop_rsync
;;
restart)
stop_rsync
start_rsync
;;
*)
echo
"USAGE:$0 {start|stop|restart}"
exit1
esac
|
本文转自 baishuchao 51CTO博客,原文链接:http://blog.51cto.com/baishuchao/1943177