Need help with a date within a script
Hi,
I am trying to write this script to monitor a log file within the last 10 lines and take the current time and subtracted by 15 minutes. I am stuck at the date calculation part. date Thu Oct 8 09:08:50 CDT 2009 I would like to know the syntax on how to take this time current time and subtracted by 15 minutes. Help! Thank you in advance. J |
What scripting language are you using? It would probably be easiest to use the unix timestamp to do the subtraction then convert back to the date format you want.
|
I hope this isn't homework.
date can easily do this for you. Try date -d "now -15 minutes" |
Try this:
Code:
date -d @$[$(date +%s) - (15*60)] |
Quote:
The date command can do this for bash, read the man page. For example: Code:
date --date="-1 days" +%Y%m%d |
Until I tried mine, we got the real answer;)
|
All times are GMT -5. The time now is 04:19 AM. |