rc.local

/etc/init.d/nginx start

查看运行状态

systemctl status rc-local
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: failed (Result: exit-code) since 六 2018-07-07 09:40:03 CST; 5min ago
Process: 1112 ExecStart=/etc/rc.local start (code=exited, status=1/FAILURE) 7月 07 09:40:03 Ubuntu systemd[1]: Starting /etc/rc.local Compatibility...
7月 07 09:40:03 Ubuntu rc.local[1112]: Starting nginx... nginx: [emerg] host not found in upstr
7月 07 09:40:03 Ubuntu rc.local[1112]: failed
7月 07 09:40:03 Ubuntu systemd[1]: rc-local.service: Control process exited, code=exited status
7月 07 09:40:03 Ubuntu systemd[1]: Failed to start /etc/rc.local Compatibility.
7月 07 09:40:03 Ubuntu systemd[1]: rc-local.service: Unit entered failed state.
7月 07 09:40:03 Ubuntu systemd[1]: rc-local.service: Failed with result 'exit-code'.

发现是失败的,原因大概是没有exit 0,再次尝试重启

rc.local

/etc/init.d/nginx start
exit 0

重启rclocal

systemctl restart rc-local
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (running) since 六 2018-07-07 09:46:42 CST; 1min 49s ago
Process: 3796 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
Main PID: 3801 (nginx)
CGroup: /system.slice/rc-local.service
├─3801 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/ng
├─3804 nginx: worker process
├─3805 nginx: worker process
├─3806 nginx: worker process
└─3807 nginx: worker process 7月 07 09:46:42 Ubuntu systemd[1]: Starting /etc/rc.local Compatibility...
7月 07 09:46:42 Ubuntu rc.local[3796]: Starting nginx... done

再次查看状态,发现成功了nginx。通过这两条指令不需要每次都重启电脑进行调试了,而且重启电脑也不知道什么原因会启动失败。

可以通过这样来检测开机启动是否能成功,而不是每次都要重启,重启!

还可以查看其他服务的启动情况!

systemctl status nginx
● nginx.service - LSB: starts the nginx web server
Loaded: loaded (/etc/init.d/nginx; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since 六 2018-07-07 10:13:22 CST; 3min 33s ago
Docs: man:systemd-sysv-generator(8)
Process: 939 ExecStart=/etc/init.d/nginx start (code=exited, status=1/FAILURE) 7月 07 10:13:17 Ubuntu systemd[1]: Starting LSB: starts the nginx web server...
7月 07 10:13:22 Ubuntu nginx[939]: Starting nginx... nginx: [emerg] host not found in upstream
7月 07 10:13:22 Ubuntu nginx[939]: failed
7月 07 10:13:22 Ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1
7月 07 10:13:22 Ubuntu systemd[1]: Failed to start LSB: starts the nginx web server.
7月 07 10:13:22 Ubuntu systemd[1]: nginx.service: Unit entered failed state.
7月 07 10:13:22 Ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'.

rc.local 开启自启动,检测是否成功的更多相关文章

  1. 配置rc.local开机自启动文件的疑问

    有时我们自己在/etc/rc.d/rc.local里面增加的随机器启动的脚本和指令总是不能自动加载和启动,,机器启动后手动执行脚本又能成功,经常被搞得晕头转向的.最近我经过1天的辛苦测试和查找资料,终 ...

  2. rc.local 增加自启动

    编辑 /etc/rc.d/rc.local,将要执行的命令放里面. 然后给 rc.local 增加执行权限  chmod +x rc.local . 不过该方法正在被逐步淘汰,提示建议采用自定义服务的 ...

  3. rc.local文件

    rc.local用于自启动一些服务. 查看有哪些自启动服务: cat /etc/rc.local

  4. rc.local自启动学习(转)

    linux有自己一套完整的启动体系,抓住了linux启动的脉络,linux的启动过程将不再神秘. 本文中假设inittab中设置的init tree为: /etc/rc.d/rc0.d/etc/rc. ...

  5. rc.local自启动学习

    在CentOS系统下,主要有三种方法设置自己安装的程序开机启动.1.把启动程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是设置开机启动httpd. #!/bin/sh # # ...

  6. debian9 开启rc.local服务

    由于某些软件并没有增加开启启动的服务,很多时候需要手工添加,一般我们都是推荐添加命令到 /etc/rc.local 文件,但是 Debian 9 默认不带 /etc/rc.local 文件,而 rc. ...

  7. CentOS开机自启动/etc/rc.local不执行的解决办法

    放置在开机自启动里面没有自动启动 查看文件/etc/rc.local发现是一个软连接 修改源文件的执行权限即可 chmod 755 /etc/rc.d/rc.local 查看日志可以看到开机自启动过程 ...

  8. ArchLinux For Arm 树莓派开机自启动脚本rc.local

    今天折腾了下树莓派的迅雷固件,迅雷的安装很顺利,解压直接运行portal 就搞定了, 但是自启动就有问题了,由于新版的ArchLinux切换到systemd,不但rc.conf省了,连rc.local ...

  9. 用rc.local工具开机自启动

    对于一些程序来说,无法直接开机自启动.那么我们可以利用开机自启动来执行一些命令,达到开机自启动的效果!!! 下面用tomcat来举个例子 tomcat启动的命令一般是./startup.sh 那么我们 ...

随机推荐

  1. spring-aop AnnotationAwareAspectJAutoProxyCreator类

    类图结构如上所示.

  2. ios7.1后setting中没有开启相机服务应用程序相机预览黑屏问题

    if ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){                               ...

  3. DEV GridControl 常用属性 z

    1隐藏最上面的GroupPanel gridView1.OptionsView.ShowGroupPanel=false; 2.得到当前选定记录某字段的值 sValue=Table.Rows[grid ...

  4. 一起talk C栗子吧(第八十四回:C语言实例--使用信号进行进程间通信一)

    各位看官们,大家好,上一回中咱们说的是进程间通信的样例.这一回咱们说的样例是:使用信号进行进程间通信.闲话休提,言归正转. 让我们一起talk C栗子吧! 我们在上一回中提到过进程之间通信须要解决的三 ...

  5. vue2.0 + vux 项目搭建

    1.快速搭建项目模板 因为项目使用vux,所以推荐使用vux官网的airyland/vux2 模板,vue-cli工具是vue项目的搭建脚手架 默认为 webpack2 模板,如果你需要使用webpa ...

  6. mysql创建还原点

    set autocommit = 0;   insert into t1(name) values ("user1"); savepoint p1;   insert into t ...

  7. hdu 5316 Magician 线段树

    链接:http://acm.hdu.edu.cn/showproblem.php? pid=5316 Magician Time Limit: 18000/9000 MS (Java/Others)  ...

  8. idea安装plugin

    ---恢复内容开始--- ---恢复内容结束---

  9. UVA 10526 - Intellectual Property (后缀数组)

    UVA 10526 - Intellectual Property 题目链接 题意:给定两个问题,要求找出第二个文本抄袭第一个文本的全部位置和长度,输出前k个,按长度从大到小先排.长度一样的按位置从小 ...

  10. YUV格式

    http://blog.csdn.net/u011270282/article/details/50696616 http://blog.csdn.net/acs713/article/details ...