Cleaning up after a script on shut down
Ray Parrish
crp at cmc.net
Thu Aug 27 18:37:18 UTC 2009
Oliver Grawert wrote:
> 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
>
Hello,
The scrpit has a sleep timer in a loop. Will that trap work even if the
sleep timer is in progress when Ubuntu is shut down?
Later, Ray Parrish
--
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com
More information about the ubuntu-users
mailing list