Hi, in Linux (RedHat 7) I can use
Code:
find /dir -amin -240 -a -amin +180 -exec rm {} \;
to delete files in /dir that were last accessed (-cmin for last changed) between 180 and 240 minutes ago. On my AIX 4.1 system -amin or -cmin are no implemented tests though. Maybe in your system it's available...
Grts
BTW: If you run your script every x hours with crontab why wouldn't you leave the reference file in LKBRWN's example on disk and just update it's timestamp at the end of the script with the current time, like:
Code:
#!/usr/bin/ksh
[ -f "${1}HOURFILE" ] && find /dir ! -newer "${1}HOURFILE" -type f -name '*.txt' -exec rm {} \;
touch "${1}HOURFILE"
and do the interval assignment through a parameter ($1) when invoking the script?