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

时间:2022-09-04 17:48:37

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. 字符串0.在php和js中转换为布尔类型 值是false还是true

    在php 中 $a = '0'; $b = (bool)$a; var_dump($a);//输出false 在js中官方说明: Note:If the value parameter is omit ...

  2. WSAStartup

    WSAStartup,是Windows Sockets Asynchronous的启动命令.Windows下的网络编程接口软件 Winsock1 或 Winsock2 里面的一个命令. 外文名 WSA ...

  3. iOS开发MAC下配置svn

    版本控制对于团队合作显得尤为重要,那么如何在iOS开发中进行版本控制呢?在今天的博客中将会介绍如何在MAC下配置SVN服务器,如何导入我们的工程,如何在Xcode中进行工程的checkOut和Comm ...

  4. 编写unit test以及自动化测试WebDriver

    http://msdn.microsoft.com/en-us/library/hh694602.aspx#BKMK_Quick_starts   http://www.seleniumhq.org/ ...

  5. 删除目录下所有gif的图片

    find  -name "*.gif" -exec rm -fv {} \;

  6. Project Euler #80: Square root digital expansion

    from decimal import getcontext, Decimal def main(): n = int(raw_input()) p = int(raw_input()) getcon ...

  7. 同一域名基于源ip地址分配给不同ip的dns配置--bind9.8.2

    1.安装bind.略. 2./etc/named.conf配置文件. // named.conf // // Provided by Red Hat bind package to configure ...

  8. PHP操作Redis数据库常用方法

    Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API. Redis支持的数据类型有 Stirng(字符串), Lis ...

  9. Java 8函数式接口functional interface的秘密

    Java 8函数式接口functional interface的秘密 2014年10月29日 17:52:55 西瓜可乐520 阅读数:3729   目录 [−] JDK 8之前已有的函数式接口 新定 ...

  10. gdb 调试带参数程序

    在gdb中,运行程序使用r或是run命令. 程序的运行,你有可能需要设置下面四方面的事. 1.程序运行参数. set args 可指定运行时参数.(如:set args 10 20 30 40 50) ...