zoukankan      html  css  js  c++  java
  • CentOS6 & CentOS7服务启动文件

    1.CentOS6

    (1)以rsync为例

    #!/bin/bash
    # chkconfig: 2345 20 80
    # description: rsync.sh
    function start_rsync {
            if [ ! -s /var/run/rsyncd.pid ];then
                    /usr/bin/rsync --daemon
            else
                    echo -e "33[33mRsync is already running33[0m"
            fi
    }
    
    function stop_rsync {
            if [ -s /var/run/rsyncd.pid ];then
                    kill `cat /var/run/rsyncd.pid`
            else
                    echo -e "33[33mRsync is no running33[0m"
                    return 1
            fi
    }
    
    function restart_rsync {
            stop_rsync
            if [ $? -ne 1 ];then
                    sleep 1
                    start_rsync
            fi
    }
    case $1 in
            start)
            start_rsync
            ;;
            stop)
            stop_rsync
            ;;
            restart)
            restart_rsync
            ;;
            *)
            echo -e "33[33mUsage: start | stop | restart 33[0m"
            ;;
    esac
    

    (2)给执行权限

    chmod +x /etc/init.d/rsync.sh
    

    (3)加入系统服务和开机自启

    chkconfig  --add rsync.sh
    chkconfig rsync.sh on
    

    2.CentOS7

    (1)以rsync为例

    [Unit]
    After=network.target remote-fs.target
    
    [Service]
    Type=forking
    ExecStart=/etc/init.d/rsync.sh start
    ExecReload=/etc/init.d/rsync.sh restart
    ExecStop=/etc/init.d/rsync.sh stop
    
    [Install]
    WantedBy=multi-user.target
    
  • 相关阅读:
    NUnit进行单元测试
    VSTS 安装步骤
    使用 Visual Studio Team Test 进行单元测试
    vss使用技巧
    struts 2.1 action 学习
    apache2 反向代理
    zz mysql中文
    trac ubuntu 安装
    ejb 3中bean的种类
    linux下VsFTP配置全方案
  • 原文地址:https://www.cnblogs.com/IMSCZ/p/12193623.html
Copyright © 2011-2022 走看看