Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving a file after it is 10 minutes old?

Status
Not open for further replies.
Aug 15, 2002
422
US
Hi all,

I have a Perl script on Linux that is called by cron to move all files from one directory to another. What happens every now an again is that my script will move a file from the source directory before the the file is complete causing all kinds of trouble...

I want to move the file ONLY when the file is older than 10 minutes.

Can anyone help?

Thanks,
-pd
 
Hi there,

You need to look at the stat() function. Stat() will give you the age of the file, well -- the number of seconds since inode modification which should do what you need. Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Thanks Mike!

That was actually what I ended up doing... I decided to try using the mtime though, which will track when the file was actually created in my case.

Thanks again!
-pd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top