Published Book on Amazon
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1 | |
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2 |
출판된 한글판 도서
최신 라즈베리파이(Raspberry
Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상) |
|
최신 라즈베리파이(Raspberry
Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하) |
Original Book Contents
20.3.5 Automatic Run regardless of Run Level at Booting
If you want the command or script to always run regardless of run level, you register it in the "/etc/rc.local" file. The script registered here is executed only in run level "2" ~ "5" which is a normal operation status of the system.
Here is an example for the contents of the file "/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.
# Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi
execution statement
exit 0 |
If you specify a shell command or a script in the part corresponding to the "execution statement", it will be executed automatically when booting. Multiple execution statements can be specified if necessary.