首页 > 系统服务 > 详细

Linux Service Start Automatically

时间:2020-06-18 14:03:07      阅读:70      评论:0      收藏:0      [点我收藏+]

Start a service

// take httpd for example 
/etc/rc.d/init.d/httpd start  // method 1

service httpd start  //method 2

chkconfig FOR "AUTO START SERVICE"

chkconfig --list

┌─[root@nedrain]─[~]
└──? $chkconfig --list

aegis          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off

chkconfig --level [run level] [service name] [on | off]

it will affect at next reboot, not this time

chkconfig --level 2345 httpd on // turn the httpd service on at 2, 3, 4, 5 run levels

you can alse edit the file "/etc/rc.d/rc.local", also auto run

RECOMMENDED, cause this way can also work on service installed by source code package

vim /etc/rc.d/rc.local
// the output
#!/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
/etc/rc.d/init.d/httpd start // auto start the httpd service after reboot

Linux Service Start Automatically

原文:https://www.cnblogs.com/nedrain/p/13156994.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!