通过/etc/rc.local实现开机自动拉起服务
添加服务到/etc/rc.local
如自动拉起apache服务:
/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
/usr/sbin/apachectl start
服务是关闭的
[root@limt ~]# chkconfig --list|grep http
httpd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭 [root@limt httpd]# reboot Broadcast message from root@limt
(/dev/pts/1) at 21:25 ... The system is going down for reboot NOW!
开机后http进程已经启动:
[root@limt ~]# ps -ef|grep http
root 2907 1 0 21:29 ? 00:00:00 /usr/sbin/nss_pcache 163842 off /etc/httpd/alias
root 2909 1 0 21:29 ? 00:00:00 /usr/sbin/httpd -k start
root 2984 2909 0 21:29 ? 00:00:00 /usr/bin/crlhelper 196611 2909 /etc/httpd/alias
apache 2987 2909 0 21:29 ? 00:00:00 /usr/sbin/httpd -k start
apache 2988 2909 0 21:29 ? 00:00:00 /usr/sbin/httpd -k start
apache 2989 2909 0 21:30 ? 00:00:00 /usr/sbin/httpd -k start
apache 2990 2909 0 21:30 ? 00:00:00 /usr/sbin/httpd -k start
apache 2991 2909 0 21:30 ? 00:00:00 /usr/sbin/httpd -k start
apache 2992 2909 0 21:30 ? 00:00:00 /usr/sbin/httpd -k start
apache 2993 2909 0 21:30 ? 00:00:00 /usr/sbin/httpd -k start
apache 2994 2909 0 21:30 ? 00:00:00 /usr/sbin/httpd -k start
apache 2995 2909 0 21:30 ? 00:00:00 /usr/sbin/httpd -k start
对于有些服务最好在启动前先停止服务,因为有些服务进程有LOCK文件,如果异常停机后LOCK文件没有删除,在随机启动的时候会报服务已启动,通过在启动前先停止服务开消除LOCK文件来正常启动服务
如:
#!/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
/usr/sbin/apachectl stop
/usr/sbin/apachectl start
通过/etc/rc.local实现开机自动拉起服务的更多相关文章
- /etc/rc.d/rc.local linux启动自动开启某些服务(转)
/etc/rc.d/rc.local似乎是很多Linux系统管理员的偏爱,因为凡是需要随系统自动启动的服务.程序等,只要系统没有提供Sys V风格的启动脚本,就把这些需求都塞到/etc/rc.d/rc ...
- Ubuntu 18.04 启用 rc.local 设置开机启动
ubuntu18.04 不再使用initd管理系统,改用systemd. 然而systemd很难用,改变太大,跟之前的完全不同. 使用systemd设置开机启动为了像以前一样,在/etc/rc.loc ...
- CentOS中在/etc/rc.local添加开机自启动项启动失败
应项目要求需要在开机的时候启动自己的Agent程序,想当然的直接就往/etc/rc.local当中添加启动命令,结果重启之后发现什么都没有发生....一开始还以为是Python路径的问题,结果改成绝对 ...
- 关于自定义脚本rc.local里开机不启动的问题--以tomcat和perl相关的脚本为例
本文将自己遇到的一些自定义脚本加入开机启动项却不成功的问题加以说明,花费了我很长时间才得以解决,当然也多谢了自己朋友的帮忙,正是因为他们的提醒,最后才找到了解决的办法,谢谢他们!!!! 系统是cent ...
- /etc/rc.d/rc.local 自定义开机启动程序
/etc/rc.d/rc.local 用于用户自定义开机启动程序,可以往里写开机要执行的命令或脚本,线上的配置如下: [root@localhost ~]$ cat /etc/rc.d/rc.loca ...
- Mac下用Launchd实现使用rc.local执行开机启动命令
其实原理很简单,使用Launchd创建一个开机启动的服务,然后这个服务关联/etc/rc.local文件,那么接下来操作rc.local就和Linux下一样的了. 当然,这种思路还可以直接使用在~/. ...
- 用rc.local工具开机自启动
对于一些程序来说,无法直接开机自启动.那么我们可以利用开机自启动来执行一些命令,达到开机自启动的效果!!! 下面用tomcat来举个例子 tomcat启动的命令一般是./startup.sh 那么我们 ...
- Centos7下rc.local文件开机不执行…
在Centos7下,rc.local文件,开机默认是不执行的 /etc/rc.local链接的是 /etc/rc.d/rc.local文件,该文件默认不开机启动,官方建议添加一个service来实现 ...
- ubuntu16.04 下通过rc.d(rc.local)实现开机启动(未登录)anydesk
先编辑anydesk-X.X.X/init/anydesk文件,将"DAEMON=//usr/bin$NAME"改成"DAEMON=/XXX/anydesk-5.1.1/ ...
随机推荐
- Delphi中的函数指针判断是否为空
delphi函数指针 只有@@p才代表了函数指针本身的地址 assigned(p) 判断是否为空 或者用 @p=nil 来判断函数指针是不是为空 Delphi中的函数指针实际上就是指针,只是在使用 ...
- poj 2503:Babelfish(字典树,经典题,字典翻译)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 30816 Accepted: 13283 Descr ...
- HDU 1227 Fast Food
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1227 题意:一维坐标上有n个点,位置已知,选出k(k <= n)个点,使得所有n个点与选定的点中 ...
- python logging模块 basicConfig配置文件
logging.basicConfig(level=log_level, format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s ...
- filter应用案例二:权限控制
filter可以用来进行权限控制,比如admin文件夹下的文件只允许管理员进入,那么,可以给admin文件夹加上一个过滤器: 简单代码示例: import java.io.IOException; i ...
- 解读Web Page Diagnostics网页细分图
解读Web Page Diagnostics网页细分图 http://blog.sina.com.cn/s/blog_62b8fc330100red5.html Web Page Diagnostic ...
- hdu 1370 Biorthythms 中国剩余定理
Biorhythms Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- Java堆外内存的使用
堆外内存的回收见HeapByteBuffer和DirectByteBuffer以及回收DirectByteBuffer 基本类型长度 在Java中有很多的基本类型,比如: byte,一个字节是8位bi ...
- css3写箭头
左箭头 .left-arrow { position: absolute; left: 6%; top: 31%; overflow: hidden; zoom:; width: 0.4rem; he ...
- js从字符串中提取身份证号,连续18位数字
<!DOCTYPE html> <html> <head> <title>提取身份证号</title> <meta charset=& ...