rsync CentOS 7 下配置开机启动

代码实现
# 做成开机启动
cat /etc/rc.d/init.d/sersync
#!/bin/bash

start() {
    /application/sersync/bin/sersync2 -d -o /application/sersync/conf/confxml.xml &>/dev/null
}

stop() {
    killall sersync2  2>/dev/null
}
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        sleep 2
        start
        ;;
    *)
        echo $"Usage:$0  {start|stop|restart}"
        exit 1
esac
###############

###############
cat /usr/lib/systemd/system/sersync.service
[Unit]
Description=sersync service
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.d/init.d/sersync start
ExecReload=/etc/rc.d/init.d/sersync restart
ExecStop=/etc/rc.d/init.d/sersync stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target
##################

# 以上两个脚本添加执行权限
chmod +x /usr/lib/systemd/system/sersync.service /etc/rc.d/init.d/sersync
# 开机启动
systemctl enalbe sersync
systemctl start sersync
posted @ 2022-06-01 20:05  Star-Hitian  阅读(246)  评论(0)    收藏  举报