When linux is shut down, execute a script-general Linux technology-Linux programming and kernel information. The following is a detailed description. In the past few days, I have received a task to trigger the automatic shutdown of other systems through a linux system linked to the UPS low-Position Automatic shutdown function. After studying for a day yesterday, we finally implemented a linux task during shutdown or restart.
The implementation process is described as follows:
First write a script to put it in/etc/rc. d/init. d, chmod-f 777, then ln-s to/etc/rc. d/rc0.d/K01 Script Name and/etc/rc. d/rc6.d/K01 Script Name, also need ln-s to/etc/rc. d/rc3.d/S99 Script Name and/etc/rc. d/rc5.d/S99 Script Name.
Start with K indicates that the system is shut down, and start with S indicates that the system is executed at startup. Note the specification of server script writing, because the soft links opened by K may not be automatically executed when the server is shut down. Why? I haven't figured it out at the beginning. Later I can see from the Internet that when I run the K script, I will check whether there is an empty file name with the same name as the script starting with K in/var/lock/subsys, if you do not have one, you will not execute it. Therefore, you need to follow the server script compiling specifications. When you start it, you need to touch an empty file with the same name as K01 after/var/lock/subsys. you must also call/etc/rc. d/init. d/functions can receive signals from the star and stop commands. For details, refer to/etc/rc. d/rc file. I am in/etc/rc. rewrite implementation based on d/rc0.d/K01yum.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.