Hands-on task
Catch a signal with trap
Write a script /root/graceful.sh that runs in an infinite loop but catches the TERM signal and, before exiting, creates a marker file /tmp/cleanup.done. That is, on receiving SIGTERM the script should shut down cleanly, leaving that file behind. The script is handy to write in the Editor tab above the terminal: create the file graceful.sh in /root and save it.
- trap
- signals
- sigterm
- bash scripts
- graceful shutdown