Cleaning up after a script on shut down
Ray Parrish
crp at cmc.net
Mon Aug 24 21:02:45 UTC 2009
Karl Auer wrote:
> 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.
>
Hello,
I've thought this through a bit, and I do not have the script set up to
write to /tmp as it runs in a user folder named WebChange, where the
temporary files are being written.
I will write a file of file names, and upon script startup, check the
file for names to be deleted. This will additionally allow for not
deleting files associated with time outs longer than the computer is on
each day, as I will be able to get their time, and date from them to
restart the proper time out periods.
Now I need to make it read a configuration file, and load urls, and
timeouts from each line of it, and recursively call itself to load each
url to be checked. The configuration file name needs to be passed in on
the command line, so more than one script can run from differing
configuration files.
Sorry about the blogging, just thinking out loud now. 8-)
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