Cleaning up after a script on shut down

Karl Auer kauer at biplane.com.au
Mon Aug 24 00:04:42 UTC 2009


On Sun, 2009-08-23 at 16:22 -0700, Ray Parrish wrote:
> I am wondering if there is a way to catch the fact that Ubuntu is 
> shutting down from a bash script, and do some clean up for the script 
> during shut down.

Do you control the script that shuts Ubuntu down, and the script that
creates the files? If so, you can write out a file containing the names
of the files you want deleted. Add a shutdown script in the
appropriate /etc/rc.* directory that runs at the appropriate time and
deletes those files. An alternative would be a startup script that
deletes them - same result. Or even delete them in the same script that
creates them.

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

If you can change the location where those files are written, write them
in /tmp. This is automatically cleaned out at every restart.

Regards, K.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)                   +61-2-64957160 (h)
http://www.biplane.com.au/~kauer/                  +61-428-957160 (mob)

GPG fingerprint: 07F3 1DF9 9D45 8BCD 7DD5 00CE 4A44 6A03 F43A 7DEF

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20090824/1bc8ad82/attachment.sig>


More information about the ubuntu-users mailing list