1. Overview
Linux servers are widely used and can be run stably in most cases. However, the shutdown is not ruled out due to other external factors such as power outages. The server's self-starter program is especially important if no operations or operations are temporarily unable to be maintained in a timely manner.
2. Linux Server Setup 2.1 powered from Boot
The host shuts down after an unexpected outage, and when the power is restored, it wants the host to start itself. It can be set up in the host BIOS and will be supported by the general machine. Different models may not describe the same. It is typically set up in power management or in the Authority manager.
2.2 Automatic login as a user
Can be implemented by modifying the tty1.conf file.
# sudo vim /etc/init/tty1.conf
Modify The last line: The #USERNAME can be the root user completely, so that the password can be automatically entered Tty1
Exec/sbin/getty–autologin USERNAME Tty1
Or
Exec/bin/login-f USERNAME </dev/tty1 >/dev/tty1 2>&1
This simple modification under the words, you can boot directly into the Tty1 console without the need to enter any authentication credentials!
2.3 Program Self-start
After Linux is loaded, it initializes hardware and device drivers and then runs the first process init. Init based on configuration
The file continues the boot process and starts other processes. Typically, the modification is placed in the
/ETC/RC or
/ETC/RC.D or
/etc/rc?. D
The script file in the directory allows Init to start other programs automatically. For example: Edit
/etc/rc.d/rc.local file (This file is usually the last script launched by the system),
For example, the/home/username/test program is set to boot and restart, you can edit the rc.local
# vim /etc/rc.local
Add a sentence before the last exit 0:
/etc/rc.local
You can also create a startup script starttest.sh
#!/bin/sh# startup test#如果需要管理员权限echo"your passwd"sudo -S /home/username/testexit0
Then add the starttest.sh execution path to the rc.local
or add system services:
# sudo cp ./starttest.sh /etc/init.d/# cd /etc/init.d # update-rc.d starttest.sh defaults 99
Linux Server Boot automatic login and self-launcher setup