1 脚本内容 rsyncd_fun.sh
#!/bin/bash
#chkconfig: 2345 20 80
#description: start rsync and stop rsync scripts
. /etc/init.d/functions
function usage(){
echo $"usage:$0 {start|stop|restart}"
exit 1
}
function start(){
rsync --daemon
sleep 1
if [ `netstat -lntup|grep rsync|wc -l` -ge 1 ];then
action "rsyncd is started." /bin/true
else
action "rsyncd is started." /bin/false
fi
}
function stop(){
killall rsync
sleep 1
if [ `netstat -lntup|grep rsync|wc -l` -eq 0 ];then
action "rsyncd is stopped." /bin/true
else
action "rsync is started." /bin/false
fi
}
function main(){
if [ $# -ne 1 ];then
本文介绍了如何创建并配置`rsyncd_fun.sh`脚本,使其成为系统开机启动的一部分。首先,将脚本复制到`/etc/init.d`目录并赋予执行权限,然后通过测试命令启动、停止和重启服务。最后,使用`chkconfig`添加并启用开机启动项。
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



