How can i display time 5mins ago on Solaris 10

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2007
Posts: 34
Reputation: skelly16 is an unknown quantity at this point 
Solved Threads: 0
skelly16 skelly16 is offline Offline
Light Poster

How can i display time 5mins ago on Solaris 10

 
0
  #1
Aug 26th, 2009
Hi

Im writing a script where im using the date command in this format.

[Datestart=`date '+%m/%d/%Y':'%H:%M:%S'`]

Is their a way to force the date variable above to go back 5minutes??

I know their is a way in perl but i prefer writing this script in ksh
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: How can i display time 5mins ago on Solaris 10

 
0
  #2
Aug 26th, 2009
Shell Scripting Syntax (Toggle Plain Text)
  1. $ date '+%m/%d/%Y':'%H:%M:%S' ; date --date='now -5 minutes' '+%m/%d/%Y':'%H:%M:%S'
  2. 08/26/2009:18:25:41
  3. 08/26/2009:18:20:41
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 34
Reputation: skelly16 is an unknown quantity at this point 
Solved Threads: 0
skelly16 skelly16 is offline Offline
Light Poster

Re: How can i display time 5mins ago on Solaris 10

 
0
  #3
Sep 1st, 2009
Hi Salem

Tried that on Solaris 10

[date '+%m/%d/%Y':'%H:%M:%S' ; date --date='now -5 minutes' '+%m/%d/%Y':'%H:%M:%S'
09/01/2009:11:11:30
date: illegal option -- date=now -5 minutes
usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]
]
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: How can i display time 5mins ago on Solaris 10

 
0
  #4
Sep 1st, 2009
Looks like you've got a crappy date then, and you need to use the perl way you know.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 558 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Shell Scripting
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC