/********************************************************************** * Automatic startup after Linux process exits * Description: * In the system, we sometimes want the daemon to be able to run all the time, even if the program is wrong, * also want the program to start automatically, and continue to run. * 2016-12-10 Shenzhen Nanshan Ping Shan village Zengjianfeng ************************************************************* ********/One, reference document: How to automatically restart a Linux background processifIt fails?http://superuser.com/questions/507576/how-to-automatically-restart-a-linux-background-process-if-it-failsSecond, the solution:1as described in the reference documentation, there are three cases:1. BusyBox init: In/etc/inittab Add::: respawn:/bin/myprocess2. Linux"System V"Init: In/etc/added in Inittab: myprocess:2345: respawn:/bin/myprocess3. SYSTEMD:1. In/etc/systemd/system/added in Myprocess.service: [Unit] Description=My Process [Service] Execstart=/bin/myprocess Restart=Always [Install] Wantedby=multi-User.target2. Systemctl Enable Myprocess.service2For more information, please refer to: http://Buildroot.uclibc.org/downloads/manual/manual.html#_init_system 3. Systemctl Start Myprocess.service
Automatically starts after the Linux process exits