« November 2020 | Home

Archive for March 2022

function cleanexit {} - Clean your shit!

Posted on Thu, Mar 31, 2022 at 16:07 by Hubertus A. Haniel

When writing scripts that create temporary files I prefer to stick a clean exit function at the top of the script that runs the clean up no matter how the script exits - this should even remove files when the script got interrupted:

	function cleanexit
{
rm -f /var/tmp/tmpfile
}
trap cleanexit INT QUIT TERM EXIT

Let me know if you have a better idea!

Edited on: Thu, Mar 31, 2022 16:28

« November 2020 | Top