scripts

Georg Wilckens durandal at nfinity.de
Sun Jun 11 02:17:14 PDT 2000


On Sat, Jun 10, 2000 at 01:32:54PM -0700, Michael A. Peters wrote:
> >hi
> >
> >i want to set up a script on my system that runs once a day, to clean out
> >temp. directories, check the filesystem and other things, but i can't work
> >out how i can check if the scripts already been run for that day.
> 
> Just tell cron to run it once a day. If it doesn't run one day, will 
> something bad happen?

Not necessarily, but what do you have cron for, if its programs never
run. I might want to put in updatedb(1) to run once a week and if for
some unfortunate reason my machine isn't running at the precise moment
of time, this action was scheduled for, three weeks in a row, that
might just annoy me.

> /tmp get cleaned out every time you boot. /var/tmp doesn't- but I'd 
> be careful how you told it to be cleaned out- you'd hate to clean out 
> a temp file that some program was using.

According to my brand new LFS-Installation - it doesn't. Erasing a
temp file which someone had open doesn't hurt - unless the file was
closed and will still be needed.
Btw. what command should be used to clean out tmp? rm -rf /tmp?
Doesn't follow symlinks, does it? What about hardlinks?
Hmm... wondering. Maybe rm -d, but that damages the filesystem.

> >i've been thinking along the lines of 'touch'ing a file after the script has
> >been run and then before the script is run check the datestamp of that file,
> >if the dates the same don't run the script if it's different run the
> >script - but i just can't work out how to check the timestamp.
> 
> make a directory somewhere- /var/tmp/whatever and add this to the end 
> of the script:
> 
> DATE=`date "+%Y%m%d"`
> rm -rf /var/tmp/whatever/?*
> touch /var/tmp/whatever/$DATE-ran
> 
> To check if the script ran, just see if /var/tmp/whatever/$DATE-ran exists.

Yes, but he wanted to do this on a regular basis - automatically. But
cron should do the job....

Regards,
	Georg
-- 
Georg Wilckens <durandal at nfinity.de>

The human mind ordinarily operates at only ten percent of its capacity
-- the rest is overhead for the operating system.

--
Mail archive: http://www.pcrdallas.com/mail-archives/lfs-discuss
IRC access: server: irc.linuxfromscratch.org port: 6667 channel: #LFS
News Reader access: news.pcrdallas.com
Unsubscribe: email lfs-discuss-request at linuxfromscratch.org and put
"unsubscribe" (without the quotation marks) in the body of the message
(no subject is required)



More information about the lfs-dev mailing list