well here is my script for subtracting a day (in ruby):
def yesterday(today)
ydate = today
ydate = ydate - ( 24 * 60 * 60 ) until ( ydate.day != today.day )
return ydate
end
the "until ( ydate.day != today.day )" is in case it is run at like 24:30 on a day that daylight savings takes effect, so subtracting 24 hours doesn't result in a Time object of the same day at 01:30 (maintaining the same hour and seconds was not necessary but could have been done by pulling from the orginal Time.now). I know this explanation probably doesn't make much sense if you don't know Ruby and how Time objects work, but I could explain better if the OP wanted to go this route (or read the link I provided earlier).
This can be modified to something like this:
def 30_minutes_ago(now = Time.now)
newtime = now
newtime = newtime - ( 30 * 60 )
return newtime
end
This would return a new time object that already takes into account your system's time zone, daylight savings changes, and rollbacks spanning across a day, month, year, etc. edit: and by the way, the "now = Time.now" means you can pass in a Time object or it will default to using Time.now (the time when the method is run).
My script then reads in the log files, uses regexp with a method to pull out the lines based on the date, and then email me the results. This is all done in Ruby and I could give the code snippets if interested. Even the email is done with Ruby's own smtp method and requires no configuration of smtp on the server, it's all done in Ruby in the script.