Ravi Sir's Cards › AWS
trap cleanup
This revision card explains trap cleanup. It starts from the need that scripts must clean up always. It describes trap runs code on a signal. The how-to section notes EXIT covers normal and error exits. An example on the card is remove the lock file.
Read card text
What this card says
Why do we need it?
Scripts must clean up always.
What is it?
trap runs code on a signal.
How to do it
EXIT covers normal and error exits.
Example
Remove the lock file.
trap 'rm -f /tmp/job.lock' EXIT