- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Using mtime in the find command...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2003 01:12 AM
тАО05-28-2003 01:12 AM
Any ideas how I can do this please?
Thanks
Carlo
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2003 01:25 AM
тАО05-28-2003 01:25 AM
Re: Using mtime in the find command...
Try Here:-
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x046b42308663d611abdb0090277a778c,00.html
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2003 01:29 AM
тАО05-28-2003 01:29 AM
Re: Using mtime in the find command...
first create a file to use as a reference point on the time line for 20 minutes ago. If 20 minutes ago was May 28, 2003 11:19 you could create the file like this:
# touch 0528111903 /tmp/whenever
Check that the mtime for this file is correct:
# ls -l /tmp/whenever
-rw-r--r-- 1 jxk users 0 Maj 28 11:19 /tmp/whenever
Then cd to the directory where you want to search and
# find . ! -newer /tmp/whenever
which will list files last modified before /tmp/whenever.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2003 01:56 AM
тАО05-28-2003 01:56 AM
Re: Using mtime in the find command...
touch 0528111903 /tmp/whenever
I will need to build this "0528111903" string in a script minus 20 minutes...
Now date +%m%d%H%M%S gives me the current time but how do I make it "20 minutes ago"?
Thanks
Carlo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2003 02:37 AM
тАО05-28-2003 02:37 AM
Re: Using mtime in the find command...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2003 03:40 AM
тАО05-28-2003 03:40 AM
Solutionif you have no other possibility, you can try this where SECONDS_SINCE should hold the path to the attached script:
#!/usr/bin/sh
# Construct REF_FILE, always 20 minutes old
#
REF_FILE=/tmp/whenever
SECONDS_SINCE=$(return_seconds.sh) # path to attached....
# Subtract 20 minutes = 1200 seconds, thus:
TWENTY_AGO=$(( ${SECONDS_SINCE} - 1200 ))
# Set timezone...
export TZ=METMETDST
# Convert 20 minutes ago to a human date
HUMAN_DATE=$( echo "0d${TWENTY_AGO}=Y" | adb )
# Extract necessary info..
YEAR_20_AGO=$( echo ${HUMAN_DATE} | awk '{print $1}')
MONTH_20_AGO=$( echo ${HUMAN_DATE} | awk '{print $2}')
DAY_20_AGO=$( echo ${HUMAN_DATE} | awk '{print $3}')
HOUR_20_AGO=$( echo ${HUMAN_DATE} | awk '{print $4}'| awk -F: '{print $1}')
MINUTE_20_AGO=$( echo ${HUMAN_DATE} | awk '{print $4}'| awk -F: '{print $2}')
SEC_20_AGO=$( echo ${HUMAN_DATE} | awk '{print $4}'| awk -F: '{print $3}')
# Convert Month name to number
case $MONTH_20_AGO in
Jan) MONTH_NO=01;;
Feb) MONTH_NO=02;;
Mar) MONTH_NO=03;;
Apr) MONTH_NO=04;;
May|Maj) MONTH_NO=05;;
Jun) MONTH_NO=06;;
Jul) MONTH_NO=07;;
Aug) MONTH_NO=08;;
Sep) MONTH_NO=09;;
Oct) MONTH_NO=10;;
Nov) MONTH_NO=1i1;;
Dec) MONTH_NO=1i2;;
esac
# Delete existing - and create new reference file...
if [ -w $REF_FILE} ]
then
rm $REF_FILE
fi
touch ${YEAR_20_AGO}${MONTH_NO}${DAY_20_AGO}${HOUR_20_AGO}${MINUTE_20_AGO} $REF_
FILE
# Check that file is ok..
echo $REF_FILE|cpio -o 2>/dev/null|cpio -ivt 2>/dev/null
# End of example,Now use REF_FILE...
As the above was cut and pasted I do not know how it will appear - it worked on my system. You should adapt the month conversion in the case structure to what is appropiate for yout $LANG. May the TZ must also be changed, and perhaps you should then wait for the inevitable perl one-liner..
regards,
John K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2003 03:53 AM
тАО05-28-2003 03:53 AM
Re: Using mtime in the find command...
Nov) MONTH_NO=1i1;;
Dec) MONTH_NO=1i2;;
1i1 should of course be 11
and 1i2 should be 12
$REF_
FILE
should be $REF_FILE
regards,
John K.