[Solved] Any way to delete a file after inactivity?
Moderator: General Moderators
[Solved] Any way to delete a file after inactivity?
Well, let me make this more clear. I have a website where people can upload their files. In the FAQ it explains that files are deleted after 30 days of inactivity (unless they re-upload the file). Well is there a script I can use to delete the file automatically? Thanks in advance.
Last edited by Jeefo on Thu Aug 25, 2005 5:15 pm, edited 1 time in total.
-
programmermatt
- Forum Commoner
- Posts: 65
- Joined: Tue Mar 15, 2005 5:03 pm
- Contact:
Something like that...this is taken from the FAQ:programmermatt wrote:Or do you mean if the file is not accessed for 30 days?
"Q: Will my files ever be deleted?
A: They will be deleted 30 days after you upload. To keep the file before the 30 days is up, just upload the same one(s) again and check "Overwrite". They will also be deleted immediatly if it is x-rated or if it promotes any illegal activities."
I would'nt use php for that at all... Little shell script would look like (untested, it has been ages that i wrote bash)
More info about a crontab you can find at your local websearch engine...
Code: Select all
#!/bin/sh
for file in `find /var/www/uploads`
do
if ї -f "e;$file"e; ]
then
stat=`stat "e;$file"e;`
if (( $stat > 30 * 24 * 60 * 60 ))
then
`rm "e;$file"e;`
fi
fi
done