Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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.


  2. #2
    use the date command and the 'seconds since Epoch' output format, e.g.:
    now=$(date +%s)
    reboot1=$(date +%s -d 'Jun 20 01:06:12')
    diff=$(($now - $reboot1))
    echo "reboot 1 happened $diff seconds ago"

  3. #3

    wow...thanks a lot....more in body

    How can i make the same work in Solaris?

  4. $spacer_open
  5. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts