[HPADM] FTP Time Stamp - SUMMARY

From: Naylor, Jim (Jnaylor@Schnucks.com)
Date: Tue Jun 29 2004 - 15:17:51 EDT


Thanks to all that replied. What worked best for me was to convert the time
stamp in the list and the date command to minutes (or seconds) and compare.
Here are the responses I received.

Fidel Ramirez:
Touch a file with a time stamp one hour earlier than when you would run your
search.
For example,
        # touch -t 06211100 ref_file
will create ref_file at 11:00 AM on Jun 21, 2004.

# ll ref_file
-rw-rw-rw- 1 root sys 71 Jun 21 11:00 ref_file

Now, you can run find in any of this ways:

        # find . -newer ref_file > list

        # find . ! -newer ref_file > list

The first form will get the list of files newer than the time stamp of
ref_file while the second form will get the list of files older than the
time stamp of ref_file.

Dave Ritchie:
every hour, touch a file on the machine - then use the -newer option to find
one hour later to look for all the newly created files...

Brett Geer:
Right, at startup of your script, get the current date and time and convert
it to unix time (the seconds since epoch thing), then get a directory
listing, convert those, determine if anything is 3600 seconds or older than
current time, voila.

David Lodge:
The easiest way to do this is to get the time field into a number of
minutes, by multiplying the hours by 60 and adding to the minutes. If you
have the 'dir' listing in list.files then you can use awk to do this:

CurrentTime=$(( ($(date +%H)*60)+$(date +%M) ))
awk -F '[ :]*' -v time=${CurrentTime} '{ filetime=($8 * 60) + $9; if (time
- filetime > 360 ) {print $1} }' list.files

This breaks if you plan to go over midnight! You can probably frig this by
using another if in the awk like:
if (filetime > time) { filetime += (24 * 60) }
So you would have:
awk -F '[ :]*' -v time=${CurrentTime} '{
filetime=($8 * 60) + $9; \
if (filetime > time) { filetime += (24 * 60) } \
if (time - filetime > 360 ) {print $1}
}' list.files

I've always found it easier to use and 'in' and 'out' directory when FTPing
- so I put files in 'in' and take files from 'out' - as this means you don't
need to mess around with trying to be intelligent!

Anil Rajapure:
Goto itrc hp forums.
Search for data hammer. It is a great utility to
compare time stamps. Get yourslf that and you can
easily compare the times.

Anoth option is to install stat() perl module on hp-ux
and comparing if file is greater/less than x value.
Hope this helps.

Thanks,
Jim Naylor
Unix Systems Administrator
Schnuck Markets, Inc.
* Direct: (314) 994-4784
*)) Cell: (314) 691-0186
* Fax : (314) 994-4684
* jnaylor@schnucks.com

-----Original Message-----
From: Naylor, Jim
Sent: Monday, June 21, 2004 1:35 PM
To: Hpux-Admin@Dutchworks. Nl (E-mail)
Subject: [HPADM] FTP Time Stamp

Good Day All,
I have search the archives for an answer to this question but have not found
a good answer. I need to ftp to an NT box and determine if any of the files
are older than one hour. If they are then I will transfer them back and
send them to another site to be processed. I though about doing a dir
listing using dir . list.files which will create a file on my local machine
called list.files. Then I would analyze the listing to determine the age of
the file. I am having a hard time determining how to convert the date into
a usable form to determine if it is more than one hour old. Any suggestions
would be greatly appreciated.

Jim Naylor
Unix Systems Administrator
Schnuck Markets, Inc.
jnaylor@schnucks.com
314-994-4784

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact
majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner:
owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse
only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse &
search)
--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:41 EDT