How to Get Linux Boot Time

Linux uptime command will show how long the system has been running. But if you want to find out the boot time of the system instead, you will have to perform a bit of arithmetic – subtract the output of the uptime command from the current time. Sounds too troublesome? There’s an easier way to do it using the Linux proc filesystem.

In the file /proc/stat, there is a special entry ‘btime’ which is the system boot time expressed in number of seconds since epoch (1-Jan-1970). We can convert the ‘btime’ to a human-readable date format by using the date command.

admin@router01:/# cat /proc/stat | grep btime
btime 1381141952
admin@router01:/# date --date=&quot;@<code>cat /proc/stat | grep btime | cut -f 2 -d' '</code>&quot;
Mon Oct  7 18:32:32 GMT 2013

If you are wondering, the above is the output from my Linux powered WiFi router!

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }