一、添加开机启动脚本

#!/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

  

centos7之添加开机启动服务/脚本的更多相关文章

  1. 【centos7】添加开机启动服务/脚本

    一.添加开机自启服务 在centos7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例): systemctl enable jenkins.service #设置jenkins服务为 ...

  2. centos7如何添加开机启动服务/脚本

    一.添加开机自启服务 在centos7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例): systemctl enable jenkins.service #设置jenkins服务为 ...

  3. (转) CentOS 7添加开机启动服务/脚本

    CentOS 7添加开机启动服务/脚本 原文:http://blog.csdn.net/wang123459/article/details/79063703 一.添加开机自启服务 在CentOS 7 ...

  4. CentOS7添加开机启动服务/脚本(延用CentOS6方法)

    一.添加开机自启服务 在centos7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例): systemctl enable jenkins.service #设置jenkins服务为 ...

  5. CentOS 7添加开机启动服务/脚本

    一.添加开机自启服务 在CentOS 7中添加开机自启服务非常方便,只需要两条命令(以 jenkins 为例):systemctl enable jenkins.service #设置jenkins服 ...

  6. CentOS 7添加开机启动服务脚本

    一.添加开机自启服务 在CentOS 7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例): systemctl enable jenkins.service #设置jenkins服务 ...

  7. Linux—添加开机启动(服务/脚本)

    系统启动时需要加载的配置文件 /etc/profile./root/.bash_profile/etc/bashrc./root/.bashrc/etc/profile.d/*.sh./etc/pro ...

  8. Centos7 下添加开机自启动服务和脚本

    1.添加开机自启服务 #设置jenkins服务为自启动服务 systemctl enable jenkins.service #启动jenkins服务 systemctl start jenkins. ...

  9. centos7如何添加开机启动项?

    centos7提供开启服务启动的方式: 1.系统服务管理命令,如果是通过yum安装的软件,开机启动脚本,已经自动创建好了,直接执行如下命令 nginx.service后缀可以省略 systemctl ...

随机推荐

  1. Beanstalkd,zeromq,rabbitmq的区别

    1).rabbitmq(功能强大,管理应用也完善,不过也比较重量级)2).zeromq(从rabbitmq出来的一个小而快速的队列,基本是目前最快的队列机制,自身支持多种模式,可以对各个模式进行自己组 ...

  2. MySQL Err(1024):Lock wait timeout exceeded; try restarting transaction

    查看事务是否占用被锁: SELECT * FROM information_schema.INNODB_TRX;查看里面的 trx_mysql_thread_id字段 show full proces ...

  3. linux学习笔记-配置vbox虚拟机本地连接和外网同时可用

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! 在设置网络里面启用两个网卡,一个桥接,一个网络地址转换 archlinux系统下第一个网络地址转换,第二个桥接 centos7系 ...

  4. Mac 终端 显示隐藏文件

    defaults write com.apple.finder AppleShowAllFiles Yes && killall Finder //显示隐藏文件 defaults wr ...

  5. Android 图片加载框架 Glide4.x

    概述 Glide是一个图片加载框架,使得我们可以轻松的加载和展示图片 Glide4.x新增apply()来进行设置,apply可以调用多次,但是如果两次apply存在冲突的设置,会以最后一次为准 新增 ...

  6. python读取txt文件最后一行(文件大+文件小)

    txt文件小 #coding:utf-8 ''' fname为所读xx.txt文件 输出为:文件第一行和最后一行 ''' fname = 'test.txt' with open(fname, 'r' ...

  7. Tomcat开启SSL协议支持

    一.生成keyStore 要使用ssl connector,必须先创建一个keystore.他包含了服务器中被客户端用于验证服务器的数字证书.一旦客户端接受了这个证书,客户端就可以使用public k ...

  8. mysql 将一个表中的数据复制到另一个表中,sql语句

    1.表结构相同的表,且在同一数据库(如,table1,table2) Sql :insert into table1 select * from table2 (完全复制) insert into t ...

  9. LeetCode算法题-Quad Tree Intersection(Java实现)

    这是悦乐书的第260次更新,第273篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第127题(顺位题号是558).四叉树是树数据,其中每个内部节点恰好有四个子节点:top ...

  10. django--use

    https://docs.djangoproject.com/zh-hans/2.0/intro/