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

$ date '+%m/%d/%Y':'%H:%M:%S' ; date --date='now -5 minutes' '+%m/%d/%Y':'%H:%M:%S'
08/26/2009:18:25:41
08/26/2009:18:20:41

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]
]

Looks like you've got a crappy date then, and you need to use the perl way you know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.