Re: Deleting files from O/S older than 6 hours

Another trick is to create or touch a marker file at the time you do the move, 
which you can use "next time" to tell you the O/S time to compare with:


   find files newer than marker file (see earlier post)
   move them / delete them / archive them
   touch marker file now

Then if for any reason there is a delay in launching your purge (if your script 
launcher such as the database or cron is down for any reason) the mechanism 
automatically self corrects... maybe the period is now 7 hours rather than 6. 
This also allows you to change the schedule frequency without having to change 
the script itself.

The only small issue is what happens to files added between 1 and 3 (as the 
operations aren't exactly ACID)

Regards Nigel

Other related posts: