find files 2 hours old

From: Bill Thompson (bill.thompson_at_GOODYEAR.COM)
Date: 06/17/03

  • Next message: Bruce Zimmer: "FW: SSA Blanks"
    Date:         Tue, 17 Jun 2003 07:31:54 -0400
    To: aix-l@Princeton.EDU
    
    

    John,

    Here's a script that will list all of the files on the system that are more
    than twelve hours old. The key is the computing a date 12 hours in the
    past. This is done with the following line:

    TWELVE_HOURS_AGO=$(TZ=EST17EDT16;date '+%Y%m%d%H%M')

    Note that TZ in my part of the world is "EST5EDT4". To compute the time 12
    hours ago, I just added 12 to both numbers to come up with "EST17EDT16".
    You'll have to make adjustments for your local timezone.

    Also, the subject line of your post said two hours but the body said
    twelve. No matter - If you really want to find files that are older than
    two hours (rather than twelve) just adjust the TZ variable appropriately.

    - - - - - snip - - - - -
    #!/usr/bin/sh

        # compute the time twelve hours ago in the form of "CCYYMMDDhhmm"
        TWELVE_HOURS_AGO=$(TZ=EST17EDT16;date '+%Y%m%d%H%M')

        # create the name for the temporary file
        TOUCH_FILE="/tmp/${TWELVE_HOURS_AGO}.$$"

        # get rid of the temp file if the script is aborted
        trap "rm -f $TOUCH_FILE" 1 2 3 15

        # create the temp file with a time stamp of twelve hours ago
        touch -a -m -t $TWELVE_HOURS_AGO $TOUCH_FILE

        # find all the files older than the temp file
        find / ! -newer $TOUCH_FILE -ls

        # get rid of the temp file
        rm -f $TOUCH_FILE
    - - - - - snip - - - - -

    Bill Thompson
    Sr UNIX Systems Administrator
    The Goodyear Tire & Rubber Co.

    Contains Confidential and/or Proprietary Information
    May Not Be Copied or Disseminated Without Express Consent of The Goodyear
    Tire & Rubber Company.

    AIX-L Archives: http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2

    ----- Original Message -----
    From: "John Dunn" <john.dunn@SEFAS.CO.UK>
    Newsgroups: bit.listserv.aix-l
    To: <aix-l@Princeton.EDU>
    Sent: Tuesday, June 17, 2003 3:58 AM
    Subject: find files 2 hours old

    > Is there anyway to get find to identify files that have not been modified
    > for 12 hours?
    >
    > John


  • Next message: Bruce Zimmer: "FW: SSA Blanks"

    Relevant Pages

    • Re: IntelliStation Power 275
      ... Goodyear Tire and Rubber Company ... written consent of The Goodyear Tire & Rubber Company. ... workstations will not beep? ... We have a few users who claim that they need the DVD drives on these ...
      (AIX-L)
    • Re: IntelliStation Power 275
      ... Goodyear Tire and Rubber Company ... written consent of The Goodyear Tire & Rubber Company. ... workstations will not beep? ... We have a few users who claim that they need the DVD drives on these ...
      (AIX-L)
    • Re: Big VG
      ... Senior Technical Support Analyst ... Goodyear Tire and Rubber Company ... written consent of The Goodyear Tire & Rubber Company. ... Be aware there was an issue with the chvg command and AIX 5.2... ...
      (AIX-L)
    • Re: H70 and AIX 5.3 (Update)
      ... >not figured out what went wrong, but I ended up having to remove HACMP ... >written consent of The Goodyear Tire & Rubber Company. ... You are hereby notified that any dissemination, ...
      (AIX-L)
    • Re: AIX 421 device drivers for Wide/Ultra-2 SCSI IO Controller
      ... Goodyear Tire and Rubber Company ... written consent of The Goodyear Tire & Rubber Company. ... Had a H50 with additional drives in both its "six-packs". ... H70# cfgmgr ...
      (AIX-L)