4

we are using hp-ux servers we need to get 2 hours ago datetime value in bash shell script ?

how can i do that any experiences ?

soField
  • 2,536
  • 9
  • 36
  • 44

2 Answers2

7
date -d -2hours; date --version

Thu Apr 14 02:38:08 CEST 2011
date (GNU coreutils) 7.4

user unknown
  • 35,537
  • 11
  • 75
  • 121
1

I'm not a shell script expert, but you may want to check this site at unix.com. They provide this example for subtracting from dates:

   # subtract from any date
    date --date "$dte 3 days 5 hours 10 sec ago"
    date --date "$dte -3 days -5 hours -10 sec"
JYelton
  • 35,664
  • 27
  • 132
  • 191