Computing.Net > Forums > Unix > How to remove files after 6 hours

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

How to remove files after 6 hours

Reply to Message Icon

Original Message
Name: codunix
Date: August 19, 2005 at 13:50:14 Pacific
Subject: How to remove files after 6 hours
OS: HP-UX
CPU/Ram: 2 Gig
Comment:

Is there any way/script to find and remove the files which are older than 6 hours, since the files are generated at frequent intervals. These files grow at a rapid rate and fills up the disk quickly. Appreciate your response. Thanks


Report Offensive Message For Removal


Response Number 1
Name: David Perry
Date: August 22, 2005 at 11:36:55 Pacific
Reply:

Run this every 6 hours from cron.

if [ -a /tmp/timestamp ] ; then
find /full/path/to/tmp/directory -type f -newer /tmp/timestamp -exec rm -f {} \;
fi

touch /tmp/timestamp


Report Offensive Follow Up For Removal

Response Number 2
Name: codunix
Date: August 22, 2005 at 13:19:58 Pacific
Reply:

Could you please explain what exactly is in '/tmp/timestamp'?


Report Offensive Follow Up For Removal

Response Number 3
Name: David Perry
Date: August 23, 2005 at 07:21:22 Pacific
Reply:

The script is not dependent on the content of /tmp/timestamp. The touch command will either create an empty file or update the timestamp of a file based on date time information used.

man touch

The -newer flag for find says to find files newer that some file.

man find


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home



Results for: How to remove files after 6 hours

How to remove files
    Summary: Hi, In a directory in Unix OS. how to remove all files except the files whose name start with x? regards Ravi ...
www.computing.net/answers/unix/how-to-remove-files/7421.html

How to Remove LILO from Windows NT boot
    Summary: Dear Sir, I am also under a similar problem as you. I have loaded linux madrake which has become the boot loader. After loading from the Linix boot selector, for 'dos' which is the ntpartion I get the...
www.computing.net/answers/unix/how-to-remove-lilo-from-windows-nt-boot-/2230.html

How to search files after a specefi
    Summary: Ya dear I tried the upper suggestions , but i still find files older . eg. I wanted to see created files after 4 april 2002. but it also shows me files which were created before 04 April 2002 infact ...
www.computing.net/answers/unix/how-to-search-files-after-a-specefi/5836.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes Today.
Discuss in The Lounge
Poll History






Data Recovery Software