zoukankan      html  css  js  c++  java
  • centos7之添加开机启动服务/脚本

    一、添加开机启动脚本

    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
    # that this script will be executed during boot.
    
    touch /var/lock/subsys/local
    #添加开机启动inotify.sh脚本
    /root/inotify.sh

    方法一

    注意、服务也可以使用下面方法设置开机启动,如追加rc.local文件追加/usr/bin/rsync --daemon就是开启启动rsync服务

    1、首先,脚本具有可执行权限

    chmod 755 inotify.sh
    

    2、然后将脚本存放的绝对路径+脚本全名追加到/etc/rc.d/rc.local文件最后

    /root/inotify.sh
    

    3、在centos7中,/etc/rc.d/rc.local的权限被降低了,所以需要执行如下命令赋予其可执行权限

    chmod +x /etc/rc.d/rc.local
    

      

    方法二

    1、将脚本移动到/etc/rc.d/init.d目录下

    mv /opt/script/inotify.sh /etc/rc.d/init.d
    

    2、增加脚本的可执行权限

    chmod +x /etc/rc.d/init.d/inotify.sh
    

    3、添加脚本到开机自动启动项目中

    cd /etc/rc.d/init.d
    chkconfig --add inotify.sh
    chkconfig inotify.sh
    

     注意!

      你直接把你的平时写的加的脚本这样chkconfig --add 肯定是要报service inotify.sh does not support chkconfig 错误的,不过你只需要在#!/bin/bash下面加上如下内容就行。

    #chkconfig: 345 88 14
    

      

  • 相关阅读:
    异常单据锁定涉及的数据库表
    用友通只启用核算模块
    一个迟到MM如何让老师疯掉的
    偷偷看,别笑出声啊
    安装时又提示删除程序
    自动折行的设置
    酒后百态新编 恶搞
    系统管理中“站点”“运行状态”的含义
    神经病女士银行取钱
    HDOJ 1017
  • 原文地址:https://www.cnblogs.com/lei0213/p/8595030.html
Copyright © 2011-2022 走看看