Link to home
Create AccountLog in
Avatar of jjc_mn
jjc_mn

asked on

Is there a command that will show the last time a Linux box was booted

Is there a command that will show the last time a Linux box was booted. I know the boot.log file will show it but I was looking for something like Solaris's "who -b" command to implement in a script.
SOLUTION
Avatar of nixfreak
nixfreak

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I use /dev/console date.
Avatar of Steve Bink
Try this:

# grep 'btime' /proc/stat | awk '{print strftime("%c",$2)}'
Avatar of jjc_mn
jjc_mn

ASKER

I don't have access to the console. When I run the command "/dev/console date."it appears to hang in my telnet connection.
Avatar of jjc_mn

ASKER

My /proc/stat file is zero bytes. It was rebooted today. Will it show something tomorrow?
It should show something almost immediately I would think.  It is an aggregate file for certain aspects of kernel activity.  What version are you running?  uname -a
Avatar of jjc_mn

ASKER

cat redhat-release
Red Hat Linux Advanced Server release 2.1AS (Pensacola)
# uname -a
Avatar of jjc_mn

ASKER

Linux XXnameXX 1 2.4.9-e.27smp #1 SMP Tue Aug 5 15:49:54 EDT 2003 i686 unknown
I see no reason why your /proc/stat file should be blank.  You're using a proprietary version of Linux, though, so I would guess the reason is in there somewhere.  /proc/stat is a 'pseudo-file' created by the kernel to report certain statistics.  It should be 'updated' automatically as the kernel moves through work.

I suggest you contact Redhat support for more information on this.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of jjc_mn

ASKER

I thought date was an argument to /dev/console :)
Are you sure RHEL2.1 who command doesn't support -b as it exists in RHEL3.0
Avatar of jjc_mn

ASKER

who -b
who: invalid option -- b
Try `who --help' for more information.

who help not showing it
Oh well, obviously something that was added between RHEL 2.1 and 3