I have a script that creates a temporary file, writes to it, and renames it to another file. Sometimes the script is interrupted whilst it's running so the temporary file never gets renamed to the original, which I don't want to happen. I guess this isn't an uncommon problem, so can someone point me in the right direction of how to deal with this properly?
I'm guessing I'll have to call the script with a wrapper of some sort that checks to see if everything's done properly, but if there's a way to get the script to clean up after itself, that would definitely be a much neater (sic) method.