zoukankan      html  css  js  c++  java
  • centos7下自定义服务启动和自动执行脚本

    systemctl list-units --type=service #查看所有已启动的服务

     systemctl enable httpd.service   #加入开机自启动服务

     systemctl enable rsyncd.service   #同步数据的服务

    2、开机后执行自定义脚本

    1)编辑自启动脚本的文件

    vim /yourpath/serverstart_all.sh
    
    #!/bin/bash
    sh /yourserverpath/server_start.sh

    2)将脚本标记为可执行文件

    chmod +x /yourpath/serverstart_all.sh

    3)将/etc/rc.d/rc.local文标记为可执行文件

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

    4)编辑/etc/rc.d/rc.local文件,增加 自启动脚本的执行

    vim /etc/rc.d/rc.local
    /yourpath/serverstart_all.sh

     这里做了个启动后的测试,在serverpath的log下输出结果文件,重启后输出正常

    filename="/yourserverpath/log/`date +%y%m%d_%H%M%S_`"
    sh /yourserverpath/server_start.sh>$filename"servername.log"

     3、开机后制动检测并启动特定进程 

    ps aux|grep yourprocessname

  • 相关阅读:
    synchronized的原理
    ThreadLocal是什么?使用场景有哪些?
    什么是死锁?死锁产生的原因?
    15-错误
    14-异常处理
    13-接口
    12-方法
    11-结构体
    10-指针
    09-字符串
  • 原文地址:https://www.cnblogs.com/mousean/p/6038026.html
Copyright © 2011-2022 走看看