in reply to Easy way to Remove Files if match condition time?

Get the current time with time.
Get a list of the files in your temp directory with glob or opendir.
Get the creation time of each file with stat.
See if the difference between now and the ctime is greater than (60 * 60 * 24 ).
If it is, delete the file with unlink.
  • Comment on Re: Easy way to Remove Files if match condition time?

Replies are listed 'Best First'.
Re^2: Easy way to Remove Files if match condition time?
by dave_the_m (Monsignor) on Feb 05, 2005 at 00:23 UTC
    Get the creation time of each file with stat.
    See if the difference between now and the ctime is greater than (60 * 60 * 24 ).
    Ahem, ctime is the inode modification time, not the creation time. UNIX at least, doesn't record that information.

    Dave.

      You're right, but as these were described as temp files it's probably safe to bet that they were created once and not modified after. I should have been more clear about that though.
        your probably right, the file would be created once only.