Quote:
Originally Posted by wubrgamer
...I would like make a file available for download, but only for a short amount of time (say 48 hours) and then after that, remove the file. without having to manually removing the file? (as I have been doing through an FTP client.)
|
Set up a cron job which compares the timestamp when the file was uploaded to the current time.
HINT: look at the
+%s switch of
date(1) which will return the number of seconds since the epoch.
- Substracting the upload timestamp from the current timestamp will yield the number of seconds lapsed since uploading.
- Convert 48 hours into seconds & if the lapsed time is greater than this threshold, delete the file.
- Iterate over all files you want to make available for only a prescribed amount of time.
This is one way you might do it within a shell script. Perl or Python will have modules which can look at elapsed time as well.