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
本文来自博客园, 作者:Star-Hitian, 转载请注明原文链接:https://www.cnblogs.com/Star-Haitian/p/16335492.html
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号