zoukankan      html  css  js  c++  java
  • linux 开机启动

    linux设置开机服务自动启动
     
    [root@localhost ~]# chkconfig --list     显示开机可以自动启动的服务 
    [root@localhost ~]# chkconfig --add *** 添加开机自动启动***服务 
    [root@localhost ~]# chkconfig --del ***   删除开机自动启动***服务 
      www.2cto.com  
    [root@localhost ~]# setup     可以在shell图形终端里面配置的命令,去service里选择 
    [root@localhost ~]# ntsysv    在shell终端图形配置开机启动服务命令,选项没上面那个多 
     
    setup 、rc.local 和chkconfig三种方式都可以设置 
     
    第一种) 
    输入#setup指令进入系统服务菜单,选择你想启动的服务比如httpd,然后重起机器或者/etc/rc.d./init.d/httpd 
      start 
      www.2cto.com  
    第二种) 
    把启动命令放到/etc/rc.d/rc.local文件里这样就可以每次启动的时候自动启动服务了,例如对于apache,编译好apache后会在安装目录的bin下生成apachectl文件,这是个启动脚本,我们只需要把这个命令加到rc.local里就可以了
    (suse没有rc.local。SUSE是可以这么定义自己的脚本的,如果希望在切换运行级之前和之后运行自己的脚本,那么可以分别创建: 
    /etc/init.d/before.local 
    /etc/init.d/after.local) 
    echo /usr/local/apache/bin/apachectl>> /etc/rc.d/rc.local, 
    设置服务自动启动的方式是在rc.local里还可以加入类似以下的一些脚本: 
    #sshd 
    /usr/local/sbin/sshd 
     
    #proftpd 
    /usr/local/sbin/proftpd 
     
    #apache 
    /home/apache/bin/apachectl start 
     
    #mysql 
    /home/mysql/bin/safe_mysqld --port=3306 & 
     
    #start oracle8i listener first 
    su - oracle -c 'lsnrctl start' 
    #start oracle8i 
    su - oracle -c 'dbstart' 
     
    第三种) 
    通过chkconfig指令. 
    使用chkconfig命令来把某项服务加到系统的各项运行级别中,步骤如下, 
    1 创建启动脚本. 
      对于apache,mysql,ssh这样的软件都是自己带的,我们只要稍微修改一下使之支持chkconfig就可以了 
    2 修改脚本 
    我们需要在脚本的前面加上一下2行,才能支持chkconfig命令 
    # chkconfig: 2345 08 92 
    # description: Automates a packet filtering firewall withipchains. 
     
    chkconfig:后面定义的使启动服务的运行级别(例子中使2345启动改服务),以及关闭和启动服务的顺序,(上例中关闭服务的顺序使8,启动的顺序使92) 
    descriptions:对改服务的描述(上例中是ipchains包过滤),你可以换成自己想要的 
     
    修改好之后执行 
    cp 你的脚本 /etc/rc.d/init.d/脚本名 
    chmod 700 /etc/rc.d/init.d/脚本名 
    chkconfig --add 脚本名 
    例如: 
    将其加入Linux启动过程,仅在level 3, level 5级别下运行 
    [root@Tester init.d]/sbin/chkconfig --add apache-httpd 
    [root@Tester init.d]/sbin/chkconfig --level 35 apache-httpdon 
    之后就可以了,以后每次重新启动服务器都会自动启动和关闭我们的服务了
    梦想漫步在云端,我选择了此刻起程。。。
  • 相关阅读:
    北京燃气IC卡充值笔记
    随机分析、随机控制等科目在量化投资、计算金融方向有哪些应用?
    量化交易平台大全
    Doctor of Philosophy in Computational and Mathematical Engineering
    Institute for Computational and Mathematical Engineering
    Requirements for the Master of Science in Computational and Mathematical Engineering
    MSc in Mathematical and Computational Finance
    万字长文:详解多智能体强化学习的基础和应用
    数据处理思想和程序架构: 使用Mbedtls包中的SSL,和服务器进行网络加密通信
    31-STM32+W5500+AIR202/302基本控制篇-功能优化-W5500移植mbedtls库以SSL方式连接MQTT服务器(单向忽略认证)
  • 原文地址:https://www.cnblogs.com/jessen163/p/3803021.html
Copyright © 2011-2022 走看看