Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ===== START SCRIPT /usr/local/bin/gaf ====
- #!/bin/bash
- rm -f /etc/some.config.file
- ===== END SCRIPT /usr/local/bin/gaf ====
- ===== START /etc/inittab ====
- 96:0123456:once:/usr/local/bin/gaf
- 97:0123456:powerfail:/usr/local/bin/gaf
- 98:0123456:ctrlaltdel:/usr/local/bin/gaf
- 99:0123456:kbrequest:/usr/local/bin/gaf
- ===== END /etc/inittab ====
- Explanation:
- /etc/inittab is the init configuration file, entries here have following format:
- id:runlevels:action:cmd
- Actions:
- once: execute cmd only once as soon as the system reaches specified runlevel
- powerfail: The process will be executed when the power goes down. Init will NOT wait for the process to finish before continuing
- ctrlaltdel: The process will be executed when init receives the SIGINT signal. This means that someone on the system console has pressed the CTRL−ALT−DEL key combination. Typically one wants to execute some sort of shutdown either to get into single−user level or to reboot the machine.
- kbrequest: The process will be executed when init receives a signal from the keyboard handler that a special key combination was pressed on the console keyboard
- refer to http://www.cyberciti.biz/howto/question/man/inittab-man-page.php or man inittab for details
- This case will cover every case:
- #1: If system is switched off uncleanly: at the next boot as soon as init starts it will execute the command (thanks to the id #96)
- #2: If system is switched off cleanly : as soon as system reaches runlevel 0 the system will execute the command (thanks to the id #96)
- #3: If system is rebooted : as soon as system reaches runlevel 6 the system will execute the command (thanks to the id #96)
- #4: If system lost its power: id #97 will delete the file
- #5: If somebody presses ctrl+alt+del on the keyboard: id #98 or id #99 will delete the file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement