Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a Linux FTP server that clients and project managers upload files onto to exchange files. Unfortunately, nobody ever goes in and deletes anything when they're done with it. I'm looking for an elegant way to auto-delete a file after two weeks.

I was thinking a cron job with this syntax I found online. My question is what day will it consider day 0? The day the file was created on the user's local machine, or the day it was copied to the Linux box?

find /path/to/directory/* -mtime +t -exec rm {} \;
share|improve this question
up vote 2 down vote accepted

As your parameter to find is -mtime which translates to "File's data was last modified n*24 hours ago" according to the documentation for find, it would be the date the file has been uploaded to (or modified on) your FTP server.

To determine a suitable value for +t take a look at the following section about how find rounds the time for matching:

When find figures out how many 24-hour periods ago the file was last accessed,
any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.

share|improve this answer

Consider using the -atime option instead of -mtime. It will find based on the last time the file was accessed.

share|improve this answer
Thanks, that's a great idea! – Copy Run Start Apr 24 '13 at 20:26
You might want to make sure your filesystem isn't mounted with noatime first. – Gerald Combs Jun 13 '13 at 17:50

Also, check out tmpwatch or tmpreaper.

share|improve this answer

find will use the mtime on linux box. Hopefully this is the host where FTP server is running.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.