How to determine boot time?

20,936

Solution 1

Without installing any software, you can use uptime , a native linux command, which serves to show how long computer has been running. The uptime command executed right after you boot the system will give you a general idea. However, it will take you extra seconds to enter password and login. Better approach would be to set calling uptime > /opt/BOOT.txt as part of lightdm startup script. It will be executed once the login screen shows up.

To do that , open or create /etc/lightdm/lightdm.conf file with root permissions.

It should contain the following lines:

[SeatDefaults]
greeter-setup-script=uptime > /opt/BOOT.txt

After your next reboot there will be file /opt/BOOT.txt which will tell you how long system has been up.

Alternatively you could read /proc/uptime where the first entry is uptime in seconds

Solution 2

Right after boot, run dmesg command. It shows you what you want.

Solution 3

systemd-analyze is there on ubuntu.

You can only use that if you are using systemd as boot. dmesg -d would give you time taken for each command on boot process to execute..

You can always get systemd-analyze by using

sudo apt-get install systemd systemd-analyze

Solution 4

You're looking for bootchart.

sudo apt-get install bootchart

It drops an image as well as the compressed log in your /var/log showing processes and so on.

PROTIP: You may have to run sudo update-initramfs -u -k all to get it to run at the earliest opportunity.

Share:
20,936

Related videos on Youtube

Sijan Shrestha
Author by

Sijan Shrestha

Updated on September 18, 2022

Comments

  • Sijan Shrestha
    Sijan Shrestha over 1 year

    I am just curious to know the time taken by my system to boot. In Arch Linux there is something like systemd-analyze.

    What is the alternative in Ubuntu?

    • Mohit Rajan
      Mohit Rajan about 8 years
      Yo ucould just use the same command . It worked for me
    • Sergiy Kolodyazhnyy
      Sergiy Kolodyazhnyy about 8 years
      systemd is available since 15.10 version, 14.04 still relies on upstart. So you may use that command in versions 15.10 and up
    • EdiD
      EdiD about 8 years
      @Serg small correction systemd is available since 15.04
    • Admin
      Admin about 8 years
      +1 because I see this as a better question and more clear than similarly existing one; Existing question had zero votes and its answers are either incomplete or not useful.
  • Sergiy Kolodyazhnyy
    Sergiy Kolodyazhnyy about 8 years
    Yes, except dmesg may contain other messages, for example I have in my dmesg right now a line dated [ 6467.1448 ] which is about 100 minutes after my boot. Point is that dmesg not meant specifically for boot. In between the system ready and user logging in, there may be extra message which wont tell reliable amount of time system booted
  • fais
    fais about 8 years
    +1 for using native command to measure boot time. However, the line greeter-setup-script=[command] didn't work for me. After few trials and errors, I found that greeter-setup-script=bash -c '[command]' works instead. Redirect to /tmp/test.log also works, for automated file clean up at every boot. Ubuntu and its derivative users should look for .conf file in /etc/lightdm/lightdm.conf.d/ instead.
  • fais
    fais almost 8 years
    For release newer than 14.04 (in my case 16.04), the .conf file does not exist and can be created as the answer has pointed. But I have no idea why this method doesn't work anymore in 16.04.
  • Sergiy Kolodyazhnyy
    Sergiy Kolodyazhnyy almost 8 years
    @clearkimura I'll look into it. Ping me if i forget
  • fais
    fais almost 8 years
    After repeated testing, I suspect output redirected to file may be disturbed by conflicting or delayed processes in 16.04. If user measures uptime from different location besides lightdm.conf, ensure that output is not redirected to the same file. I think this solves the issue.
  • Ken Sharp
    Ken Sharp over 6 years
    E: Unable to locate package systemd-analyze
  • Ken Sharp
    Ken Sharp over 6 years
    This is a dreadful idea and clearly won't work on a server.
  • Sergiy Kolodyazhnyy
    Sergiy Kolodyazhnyy over 6 years
    @KenSharp well, you're right about that and I agree it won't work on a server, but there was no requirement stated in the question that it has to work on a server or both server and desktop. All fair and square. I'll take your downvote, thank you very much
  • user535733
    user535733 over 6 years
    systemd-analyze is not a separate package, but the command is included in Ubuntu 16.04 and newer. It is not available in Ubuntu 14.04 and older.