Cleaning up after a script on shut down

Oliver Grawert ogra at ubuntu.com
Tue Aug 25 08:21:06 UTC 2009


hi,
Am Sonntag, den 23.08.2009, 16:22 -0700 schrieb Ray Parrish:

> I just need to remove two files on shutdown, but their names change with 
> the PID of the script.

if its a shell script, use the trap call at the top of your code, it
will automatically run the cleanup function if it catches one of the
listed signals (1 2 3 6 9 15):

--- snip ---

trap cleanup 1 2 3 6 9 15

cleanup()
{
      echo "I: Cleaning up..."
      rm -f $your_pid_file1
      rm -f $your_pid_file2
}

--- snap ---

ciao
	oli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20090825/7d61e0cc/attachment.sig>


More information about the ubuntu-users mailing list