Results 1 to 4 of 4
Hi All,
How can convert the next lines into seconds:
Jun 20 01:06:12
Jul 4 03:57:35
Jul 14 13:35:49
need to parse the messages logs every hour to see how ...
- 07-18-2011 #1Just Joined!
- Join Date
- Jul 2011
- Posts
- 2
convert reboot time from messages log into seconds
Hi All,
How can convert the next lines into seconds:
Jun 20 01:06:12
Jul 4 03:57:35
Jul 14 13:35:49
need to parse the messages logs every hour to see how many reboot were done.
Thanks
H.
- 07-18-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,842
use the date command and the 'seconds since Epoch' output format, e.g.:
Code:#!/bin/bash now=$(date +%s) reboot1=$(date +%s -d 'Jun 20 01:06:12') diff=$(($now - $reboot1)) echo "reboot 1 happened $diff seconds ago"
- 07-19-2011 #3Just Joined!
- Join Date
- Jul 2011
- Posts
- 2
wow...thanks a lot....more in body
How can i make the same work in Solaris?
- 07-19-2011 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,842
Can you install the Gnu coreutils package (which contains the date command) for Solaris on this box? If so, get it here.
Check out this thread, too, for advice on using Perl to do it, too.


Reply With Quote