zoukankan      html  css  js  c++  java
  • linux启动服务和开机自启动设置

    amba是Linux下提供的类Windows下"网络邻居"的服务。一般只有启动的时候安装了才可以启用。不过大部分Linux在安装时就已经包含了这个软件包,在启动时自动启动了服务,不过我们也可以手动启动这个服务。

    一般的Linux系统,服务一般配置在/etc/init.d或者/etc/rc.d/init.d文件夹下,国产RedFlag Linux干脆两个目录下都有对应的服务,只是/etc/init.d下面的配置成系统默认的。

    PS:RedFlag Linux还兼容Dos命令,看来是不遗余力的纵容了用户的习惯。

    下面是我在RedFlag Linux的两个服务目录下看到的(保留部分有代表性的):

    $ ls /etc/init.d $ ls /etc/rc.d/init.d 说明
    dhcpd dhcpd DHCP服务
    httpd httpd WEB服务
    ldap ldap 轻量级目录服务
    mysqld mysqld Mysql数据库服务
    proftpd proftpd FTP服务
    sendmail sendmail 邮件服务
    smb smb 网络文件服务
    sshd sshd SSH服务


    每个服务的启动:/etc/init.d/{服务名} start或者/etc/rc.d/init.d/{服务名} start
    每个服务的停止:/etc/init.d/{服务名} stop或者/etc/rc.d/init.d/{服务名} stop
    每个服务的重启:/etc/init.d/{服务名} restart或者/etc/rc.d/init.d/{服务名} restart


    比如对samba服务进行操作(对应服务名smb):

    每个服务的启动:/etc/init.d/smb start或者/etc/rc.d/init.d/smb start
    每个服务的停止:/etc/init.d/smb stop或者/etc/rc.d/init.d/smb stop

    每个服务的重启:/etc/init.d/smb restart或者/etc/rc.d/init.d/smb restart

    CentOS7的开机自启动配置

    rc.local方式

    1. 编写需要开机自启动的脚本,并添加执行权限

    test_rclocal.sh

    2. 在/etc/rc.d/rc.local配置文件中添加脚本运行命令(使用绝对路径)

    [root@dev-server-1 ~]# vim /etc/rc.d/rc.local

    #!/bin/bash

    # ...注释部分

    touch /var/lock/subsys/local

    /root/test_rclocal.sh >/dev/null 2>/dev/null

    3、添加/etc/rc.d/rc.local文件的执行权限

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

    比如禅道:

    1.编辑rc.local文件,添加shell命令

    [root@iZbp11rfoyeescusr9ha9qZ ~]# vim /etc/rc.local

    #!/bin/sh

    #

    # This script will be executed *after* all the other init scripts.

    # You can put your own initialization stuff in here if you don't

    # want to do the full Sys V style init stuff.

    touch /var/lock/subsys/local

    #执行禅道服务启动脚本

    /opt/zbox/zbox start          ##############真正添加的命令

  • 相关阅读:
    mongodb数据库shell
    PLINK pca
    xgboost 安装
    tensorflow之损失函数
    php,mysql存储过程的简单例子
    ECharts初体验
    mysql常用连接查询
    php流程控制
    php循环
    高效率php注意事项
  • 原文地址:https://www.cnblogs.com/bernard-shen/p/13178611.html
Copyright © 2011-2022 走看看