This script can be placed in the/etc/init.d/directory with service RSYNCD Start\stop\status\restart management, you can also use Chkconfig for boot-start management, detailed script content as follows:
#!/bin/bash# ******************************************************# author : wangning# Last modified:2017-10-16 19:20# Email : [email protected]# filename : rsyncd# description : # ******************************************************# chkconfig: 2345 78 79# description: this is a rsyncd script . /etc/init.d/functionsstart () { rsync --daemon &>/dev/null if [ $? = 0 ];then action "Startting rsync" /bin/true else action "Startting rsync" /bin/false fi}stop () { if [ -e /var/run/rsyncd.pid ];then kill ' cat /var/run/rsyncd.pid ' &>/dev/null action "Stopping rsync" /bin/true else echo "The rsyncd is not running" fi} Status () { if [ -e "/var/run/rsyncd.pid" ];then echo -e "\033[32m rsyncd is running \033[0m" else echo -e "\033[31m rsyncd is stopped \033[0m" fi} restart () { kill ' cat /var/run/rsyncd.pid ' &>/dev/null action "Stopping rsync" /bin/true sleep 3 rsync --daemon &>/dev/null action " Startting rsync " /bin/true}case $1 in start) start ;; stop) stop ;; status) status ;; restart) restart ;; *) echo "Usag: $0 {start |stop|status|restart} "Esac
This article is from the "Galloping Camel" blog, make sure to keep this source http://wn2100.blog.51cto.com/9915310/1973036
Rsync starts closing shell scripts