What are the differences between / etc/rc.local and / etc/init.d/rc.local in ubuntu system
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!