I'm looking for a cron to automatically delete files which is like 3 hours after last modified, excluding htaccess and index.php. any help?
crontab automate task, it does not program by itself. you will need it to call up a script, preferably a shell/bash script. The following script can help attain mod time and access time, you can go from there. Then add an entry to cron. 0 */3 * * * /path/to/script #!/bin/bash #Author: K.Sridhar #mod_acc.sh: script to find last modified and last accessed time of a file E_NOARG=65 E_MOREARG=66 if [ $# = 0 ] then echo -e '\E[31m' "Usage: $0 <filename>" tput sgr0 exit $E_NOARG elif [ $# -gt 1 ] then echo -e '\E[31m' "Please give only one file at a time" tput sgr0 exit $E_MOREARG fi LS=`which ls` MOD_TIME=`$LS -lart $1|cut -f6,7,8 -d" "` ACC_TIME=`$LS -laru $1|cut -f6,7,8 -d" "` echo "The modified time of the file is $MOD_TIME" echo "The accessed time of the file is $ACC_TIME" Code (markup):
You can delete with following command, I suggest you get used to unix commands before doing anything with shell scripts, they can be dangerous. You might wipe out your entire filesystem. rm <file> Code (markup):