Getting date and time of system startup in Linux

I found some commands here. Try who -b or last reboot | head -1.
who gives numeric dates, while last reboot returns abbreviated day / month names.


This queries the uptime from the kernel and displays it in the local timezone:

date -d "`cut -f1 -d. /proc/uptime` seconds ago"

Be careful about other options. The last command will stop working as soon as wtmp has been rotated. The who command depends on the availability and integrity of utmp. And /proc/1 might have the current date instead of the boot time date, and could even be unavailable on a hardened system. Edit: dmesg only has a fixed-length back buffer, so it is unrealiable, too. The kernel logs may be in /var/log but most distributions only keep 8 weeks of them.


I stumbled on this question while looking for a way to get a consistent, parseable boot time, as opposed to time since boot which changes on every call.

It appears that uptime -s will do the trick on most linux systems.


I found the btime line in /proc/stat when poking around a bit

cat /proc/stat | grep btime | awk '{ print $2 }'

and after a quick search, I found this page: /proc/stat explained, which outlines the "Various pieces of information about kernel activity that are available in the /proc/stat file."

The "btime" line gives the time at which the system booted, in seconds since the Unix epoch.