1

I run who -b to get the date of the last reboot. It returns 2013-10-29 14:55. Now ran by a daemon (I am sending this date to a server) it returns Oct 29 14:55. But some other times (before last reboot in Oct 29) it would return something like 2013-10-24 13:17 consistently.

First set of questions : What in an environment controls this ? Why is it different from the sudo user and the daemon ? And why did it change in between 2 reboots ?

Another question : Is there a way to have this date with format 2013-10-29 14:55 ? I could format it but the year is missing. (i.e do you know what flag to pass who -b) ?

2

This is probably due to a locale change:

$ locale | grep LC_TIME
LC_TIME="en_GB.UTF-8"
$ who -b
         system boot  2013-11-04 10:04
$ LC_TIME=C who -b
         system boot  Nov  4 10:04

Perhaps your locale was changed, and didn't take effect until after the reboot (perhaps you didn't update your environment after the change). As for why it looks different in a daemon, it probably has a different value for LC_TIME, or no value at all.

You can get the date using something like this (optionally replacing en_GB.UTF-8 with any locale that results in this format, since you may not have that locale on your system):

$ LC_TIME=en_GB.UTF-8 who -b | awk '{ print $3 " " $4 }'
2013-11-04 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.