• centos 添加开启开机自启脚本


    通过chkconfig命令

    centos 设置服务开机自动启动的方式有好多种,这里介绍一下通过chkconfig命令添加脚本为开机自动启动的方法。

    编写脚本autostart.sh(这里以开机启动redis服务为例),脚本内容如下:

    #!/bin/sh
    #chkconfig: 2345 80 90
    #description:开机自启动脚本 power by https://www.shangmayuan.com
    
    # redis
    cd /data1/redis
    redis-server /data1/redis/redis.conf

    脚本第一行 “#!/bin/sh” 告诉系统使用的shell;
    脚本第二行 “#chkconfig: 2345 80 90” 表示在2/3/4/5运行级别启动,启动序号(S80),关闭序号(K90);
    脚本第三行 表示的是服务的描述信息
    注意: 第二行和第三行必写,负责会出现如“服务 autostart.sh 不支持 chkconfig”这样的错误。

    将写好的autostart.sh脚本移动到/etc/rc.d/init.d/目录下,并给脚本赋可执行权限

    chmod +x autostart.sh

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

    chkconfig --add autostart.sh
    chkconfig autostart.sh on

    学习笔记

  • 相关阅读:
    排序算法比较及其应用
    confluence wiki 安装
    hbase优缺点
    maven nexus私服搭建
    IntelliJ Idea 2017 免费激活方法
    presto-cli通过hive查询hdfs
    monit拉起服务
    MAC nginx代理设置
    kafka-manager安装
    flume从log4j收集日志输出到kafka
  • 原文地址:https://www.cnblogs.com/TF511/p/14718357.html
Copyright © 2020-2023  润新知