Tag: Exec mil user mode script power option run use Config
Use cron to boot up
booting with/ETC/INIT.D
There are a lot of scripts under the/etc/init.d folder under the Raspberry Pi, such as cron we've learned about. This cron script wraps the cron daemon into a service that defines its behavior at startup, restart, and termination. This way, users do not need to make too complex settings when they enable the appropriate service. When the service terminates, the operating system can also automatically reclaim related resources according to the script definition. Users can also set important services to boot, save the trouble of manual opening. Therefore, we see a lot of services in the/ETC/INIT.D, such as SSH, Bluetooth, rsync and so on.
Service scripts follow a specific format:
#!/bin/SH# Start/Stop the cron daemon.#### BEGIN INIT info# provides:cron# Required-start: $remote _fs $syslog $ Time# Required-stop: $remote _fs $syslog $ Time# should-Start: $network $named slapd autofs ypbind nscd nslcd winbind# should-Stop: $network $named slapd autofs ypbind nscd nslcd winbind# Default-start:2 3 4 5# Default-stop:# Short-description:regular Background program processing daemon# Description:cron are a standard UNIX program that run S user-specified # programs at periodic scheduled times. Vixie Cron adds a # number of Features to the basic UNIX cron, including better# security and Morepowerful configuration options.### END INIT info# omitted section Case " $" inchstart) log_daemon_msg"Starting periodic command Scheduler" "Cron"Start_daemon-p $PIDFILE $DAEMON $EXTRA _opts log_end_msg $? ;; Stop) log_daemon_msg"Stopping periodic command scheduler" "Cron"Killproc-p $PIDFILE $DAEMON RETVAL=$?[$RETVAL-eq0] && [-E"$PIDFILE"] &&RM-f $PIDFILE log_end_msg $RETVAL;; Restart) log_daemon_msg"Restarting periodic command Scheduler" "Cron" $0Stop $0start;; Reload|force-reload) log_daemon_msg"reloading configuration files for periodic command scheduler" "Cron"# cron reloads automatically log_end_msg0 ;; Status) Status_of_proc-P $PIDFILE $DAEMON $NAME && exit0|| Exit $? ;;*) log_action_msg"Usage:/etc/init.d/cron {start|stop|status|restart|reload|force-reload}"Exit2 ;;EsacExit0
The /etc/init.d/myscript is not yet randomly activated. Linux on boot, the real check is the/ETC/RCN.D folder, execute the script therein. The n here represents the RunLevel. For example, at run Level 2 o'clock, Linux checks the/ETC/RC2.D folder and executes its scripts. UNIX systems can work in different operating modes, such as single-user mode, multiuser mode, and each mode is called a runlevel. Most UNIX systems follow:
Operating level: 0 shutdown, shut down 1 single user, no network connection, no daemon, not allow non-superuser login more than 2 users, no network connection, no daemon 3 users, normal boot system 4 user-defined 5 users, with graphical interface 6 restart
We need to copy the services in the/ETC/INIT.D to or establish a soft connection to the/ETC/RCN.D to service the boot at that runlevel. However, we can make use of the chkconfig command to do more conveniently:
Chkconfig--add myscript # Build script soft link to default ----del myscript # Remove Soft links
booting with/etc/rc.local
The Raspberry Pi Web site provides a way to modify the/etc/rc.local to perform user-defined tasks when the Raspberry Pi is powered on. For example, execute the date command in the file:
#!/bin/sh -"exit 0"timedate >/tmp/ 0
However, this type of startup is not recommended . /etc/rc.local is a script executed at the end of the system initialization. If you add too many tasks to this script, you will not only slow down the boot speed, but also cause management confusion. Therefore,/etc/rc.local is often used only to modify some of the parameters that need to be set during the startup process, without involving specific task launches. If you want to start some services with boot, you should avoid using/etc/rc.local.
Raspberry Pi: the best arrangement