computing
  • 0

Script To Check Files Older Than 1 Hour

  • 0

The find command on Solaris makes it hard to find files that are older than 1 hour…I can easily find those that are older than 1 day, but I need more granularity. Other than switching to Linux, which is not an option, any ideas?

From the command line, I can ls -l and awk the time element out, but what can I compare it to? Say the ls -l command shows a file ‘myfile’ with a last-modified time of ’10:30’…Now, how do I get a ‘now’ time so I can do a comparison for 10:30 < now – 1 hour ?

Thanks!

Share

1 Answer

  1. Just in case anyone is interested, this is how I was going to do it purely with sh,
    except that I was going to delete the files if they weren’t newer than yesterday. This is just my testfile

    #!/bin/sh
    outDir=/tmp
    test=`date +%m%d%H%M`
    yesterday=`expr $test – 10000`
    touch -t $yesterday ./tfile
    find . -name “*.xyz” ! -newer ./tfile -print

    • 0