Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between / etc/rc.local and / etc/init.d/rc.local in ubuntu system

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Xiaobian to share with you what the difference between/etc/rc.local and/etc/init.d/rc.local in ubuntu system, I believe most people still don't know much, so share this article for everyone's reference, I hope you have a lot of harvest after reading this article, let's go and understand it together!

/etc/init.d/rc.local

#! /bin/sh### BEGIN INIT INFO# Provides: rc.local# Required-Start: $all# Required-Stop:# Default-Start: 2 3 4 5# Default-Stop:# Short-Description: Run /etc/rc.local if it exist### END INIT INFOPATH=/sbin:/usr/sbin:/bin:/usr/bin. /lib/init/vars.sh. /lib/lsb/init-functionsdo_start() { if [ -x /etc/rc.local ]; then [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" /etc/rc.local ES=$? [ "$VERBOSE" != no ] && log_end_msg $ES return $ES fi}case "$1" in start) do_start ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;;esac

From the comments you can see that the script runs at startup level 2 3 4 5 and can only handle start arguments, then start, or/etc/rc.local if there is a file. If you want to put the boot program in the/etc/init.d/rc.local file, remember not to write all the way to the end of the file, because the script will exit in the case statement block.

/etc/rc.local

#!/ bin/sh -e## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.exit 0

There is basically no content in this script, which is to write a template for you to put the boot from the startup program. Just write your program before the exit 0 line.

So to add boot entries, simply add them to the/etc/rc.local file.

Ubuntu startup level:

0 shutdown

1 single-user

2-5 Multi-user graphical interface

6 restart

For each boot level, the/etc/directory corresponds to a directory like/etc/rc5.d/. Here are some scripts. These scripts are basically soft links corresponding to the/etc/init.d/directory. The numbers in the names represent priorities. These scripts will be executed once at boot time.

Note: My system is ubuntu 15.04

What is the difference between/etc/rc.local and/etc/init.d/rc.local in ubuntu? Thank you for reading all the contents of this article! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report