Command to find files older than 1 hour

Hi,

Out of a list of files in a directory, I want to find the files which were created/modified more than 1 hour ago. I am using HP -UNIX and it does not support the argument -mmin. Please advise.
I am using # !/bin/sh

Below timestamp corresponds to YYMMDDHHMM, please adjust it for your requirement; if required, YYYYMMDDHHMMSS should work too (see man touch ).

touch -t 1412121200 /tmp/newer

(Alternatively, you could use a reference file to take its timestamp, e.g. touch -r /path/to/reffile /tmp/newer )

find /path/to/dir -type f ! -newer /tmp/newer

Make sure you "update" your /tmp/newer file accordingly if you run find again at a later date.

The problem is I cannot hardcode the timestamp for the temp file. Since this is a script which will run every 1 hour, I want to pick only those files which were created one hour before the current timestamp.

If you run the script regularly, keep the directory's last contents and compare to the actual state.

ls -1 >old
touch Xx YY
ls -1 | grep -vf old
Xx
YY

First see if

date "+%y%m%d%H%M%S"

will work. That will give you the current timestamp one could feed to touch.

I don't know much HP-UX, but on Linux and Solaris 10, one can temporarily change the TZ (timezone) variable.

One could (ab)use it like so:

ts=`TZ="America/Los_Angeles" date "+%y%m%d%H%M%S"`

Make sure you use an appropriate and valid Continent/City combination that is 1 hour behind your current location.

If it works, you could try touch -t $ts /tmp/newer

If the current value of TZ is something like PST8PDT, try the Continent/City combination anyway.