当前位置:首页 > Linux

rc.local 开启自启动,检测是否成功

canca3年前 (2023-09-24)Linux527

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'.


扫描二维码推送至手机访问。

版权声明:本文由Ant.Master's Blog发布,如需转载请注明出处。

本文链接:https://iant.work/post/862.html

分享给朋友:

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

在Linux下安装和使用MySQL

一、引言 想使用Linux已经很长时间了,由于没有硬性任务一直也没有系统学习,近日由于工作需要必须使用Linux下的 MySQL。本以为有Windows下使用SQL Server的经验,觉得在Linux下安装MySql应该是易如反掌的事,可在真正安装和使用…

ssh 连接时出现 connection reset by peer 错误

底层原因:服务器端的防火墙不接收ssh包,并返回ICMP错误包。---------------------------------------------------------------------------------------------------------------------解…

Linux 安装Apache

本以为Apache的编译安装很简单,其实不然;  以前的环境下编译报错很少 ,但这次不行了  提示configure: error: APR not found. Please read the documentation.  经网上查阅资料才知道这是Apac…

如何通过Linux系统下iptables防火墙开启/关闭指定端口方法

一般情况下iptables已经包含在Linux发行版中.运行iptables --version来查看系统是否安装iptables 启动iptablesservice iptables startiptables --list //*查看iptables规则集*//下面是没有定义…

linux删除乱码文件

一些乱码文件不可以通过普通的rm命令进行管理。可以通过删除i节点的方式删除。[root@192_168_100_35 musicwap]# ls??,?K?k??a*.?J]?k?Φ??P???Z?b?A?R???X??u??.?????*H@B?T???xS*查看乱码文件的i结点[root@192…

用cat命令显示一个文件的最后几行

tail -10 filenamecat filename |tail -10view filename+G…

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。