centos7编写自启动脚本

  1. 编写启动脚本:
    vim srvd
    #!/bin/bash
    function start()
    {
        #  启动命令
    }
    function stop()
    {
        #  停止命令
    }
    case "$1" in
    start)
    start
    ;;  
    stop)
    stop
    ;;  
    restart)
    stop
    start
    ;;
    *)
    echo "Usage : start | stop | restart"
    ;;
    esac
  2. 加入系统启动文件夹:
    chmod  a+x  srvd
    cp  -arf  srvd  /etc/init.d/
  3. 手动启动:
    systemctl  start  srvd
  4. 设置开机自启动:
    chkconfig  --add  srvd
    chkconfig  srvd  on

猜你喜欢

转载自blog.51cto.com/12173069/2118590