The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Linux Going Big Time and Prime Time Against Windows, UNIX (WSJ) (Addict 3D) iBot UNIX and Linux RSS News 0 06-21-2007 01:10 PM
Start time/end time and status of crontab job thambi Shell Programming and Scripting 3 05-16-2007 07:24 AM
How To Provide Time Sync Using Nts-150 Time Server On Unix Network? pesty UNIX for Advanced & Expert Users 2 03-21-2007 10:20 PM
Differences between time command and usr/bin/time icedrake UNIX for Dummies Questions & Answers 1 04-24-2005 12:34 PM
default time in Solaris 8 for time-wait eloquent99 UNIX for Dummies Questions & Answers 1 04-01-2003 06:45 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-12-2006
Registered User
 

Join Date: Dec 2006
Posts: 4
Stumble this Post!
HP-UX & need help with time

I use HP-UX & need help with time.
I use a script to create a date stamp: /bin/date "+%m%d%H%M" to get: 12080826.
I need a way to use the "touch -t" command to create a
file with a timstamp 30 minutes prior to that stamp. (12080756)
Can anyone help?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-12-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 923
Stumble this Post!
The timestamp is in seconds, so to get 30 minutes prior, subtract 1800 from it.
Reply With Quote
  #3 (permalink)  
Old 12-13-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,812
Stumble this Post!
You need to have your date in epoch seconds, subtract 1800, then format it back so touch -t can use it.

Perderabo's datecalc script in the forum FAQ does this kind of thing for you - look at the date arithmetic thread.
Yesterdays Date/Date Arithmetic
Reply With Quote
  #4 (permalink)  
Old 12-13-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,430
Stumble this Post!
datecalc does not handle time, just the date.

This question involves a timestamp in minutes, not seconds. Simply subtracting 30 (rather than 1800) from it would not work shortly after midnight.

Try this:
perl -e '@d=localtime time()-1800; printf "%02d%02d%02d%02d\n", $d[4]+1,$d[3],$d[2],$d[1]'

If you have not installed a recent version of perl, the HP supplied /usr/contrib/bin/perl, which is very old, should work.
Reply With Quote
  #5 (permalink)  
Old 12-13-2006
Registered User
 

Join Date: Dec 2006
Posts: 4
Stumble this Post!
Excellent. I will give these options a try. I appreciate the help!!
Reply With Quote
  #6 (permalink)  
Old 12-13-2006
Registered User
 

Join Date: Dec 2006
Posts: 4
Stumble this Post!
Anybody know how to transfer the date into "epoch seconds" ??
Reply With Quote
  #7 (permalink)  
Old 12-13-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,430
Stumble this Post!
Quote:
Originally Posted by obrien2003
Anybody know how to transfer the date into "epoch seconds" ??
Try:
perl -e 'print time(), "\n" '
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0