当前位置:首页 > Linux > 正文内容

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

canca2年前 (2023-09-24)Linux406

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 shell下除了某个文件外的其他文件全部删除的命令

linux shell下除了某个文件外的其他文件全部删除的命令

Linux反选删除文件最简单的方法是# shopt -s extglob      (打开extglob模式)# rm -fr !(file1) 如果是多个要排除的,可以这样:# rm -rf !(file1|file2) Lin...

centos 7 crontab定时器及开机自启

crontab 建议直接采用centos7 自带得cronteb包,定时器:就是定时去执行干某一件事在这里我以脚本为媒介1 当然是创建一个脚本,创建目录随意但是你一定要记得。。直接通过vi来创建一个test.sh脚本!vi /etc/test.sh编辑脚本内容:#!/bin/bash #...

centos7 手动修改dns

方法一:vim /etc/resolv.conf# Generated by NetworkManager nameserver 114.114.114.114 nameserver 119.29.29.29重启网卡:systemctl ...

linux 系统tar文件压缩打包命令

打包成tar.gz格式压缩包# tar -zcvf renwolesshel.tar.gz /renwolesshel解压tar.gz格式压缩包# tar zxvf renwolesshel.tar.gz打包成tar.bz2格式压...

debian系统如何搭建 Samba服务器

debian系统如何搭建 Samba服务器

几乎所有的 Linux 发行版都提供了一个很好的工具 Samba来轻松实现文件共享。最近在Nanopi2 上安装了 debian 系统,然后准备搭建Samba 服务器来实现文件的共享,以下步骤仅供参考。1.执行以下指令:apt-get install samba samba-common-bin2....

armbian修改为中文环境,解决中文乱码

step1:输入 dpkg-reconfigure locales选 zh_CN.UTF-8 ,空格打钩,tab 到确定按钮即可。第二个画面 选择默认语言,随便选,这一步主要是为了安装 zh_CN.UTF-8 语言包。step2:输入 vi /etc/default/locale按 i 键,进入in...

发表评论

访客

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