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. Maven的安装文字版(Windows/Linux/Mac)

    以下内容引用自https://ayayui.gitbooks.io/tutorialspoint-maven/content/book/maven_environment_setup.html,安装信 ...

  2. Android Studio 删除项目

    在项目上右键 点击“Open Module Settings”,然后你会看到你的项目排成一列,如果想删除哪个,点击项目,然后在左上角,点击“-”号,然后返回后发现这个项目变为灰色,点击项目右键,看到“ ...

  3. python为不同的对象如何分配内存的小知识

    id方法的返回值就是对象的内存地址. python中会为每个出现的对象分配内存,哪怕他们的值完全相等(注意是相等不是相同).如执行a=2.0,b=2.0这两个语句时会先后为2.0这个Float类型对象 ...

  4. angular md-toast 颜色

    How to show md-toast with background color https://codepen.io/neilkalman/pen/jWBqve <div ng-contr ...

  5. 淘宝HSF 框架使用 总结

    @(JAVA开发) 淘宝HSF 框架使用 总结 随着网站访问量增加,仅仅靠增加机器已不能满足系统的要求,于是需要对应用系统进行垂直拆分和水平拆分.在拆分之后,各个被拆分的模块如何通信?如何保证性能?如 ...

  6. VUE高仿饿了么app开发思维导图

    来自互联网 文章来源:刘俊涛的博客 地址:http://www.cnblogs.com/lovebing

  7. hdu 4432 数学杂题

    http://acm.hdu.edu.cn/showproblem.php?pid=4432 6分钟写的代码,一上午去调试,, 哎,一则题目没看懂就去写了,二则,哎,,恶心了.在坚持几天然后ACM退役 ...

  8. HDU 1698 Just a Hook(线段树区间替换)

    题目地址:pid=1698">HDU 1698 区间替换裸题.相同利用lazy延迟标记数组,这里仅仅是当lazy下放的时候把以下的lazy也所有改成lazy就好了. 代码例如以下: # ...

  9. git clean

    使用git clean清除未加入版控的数据 作者:Level Up  发布日期:2012-12-21 10:48:10       笔者在使用版本控制软件时,不知为何常常会有些暂存的数据产生.像是下面 ...

  10. UVA 11888 - Abnormal 89&#39;s(Manachar)

    UVA 11888 - Abnormal 89's option=com_onlinejudge&Itemid=8&page=show_problem&category=524 ...