7

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?

  • 2
    Yo ucould just use the same command . It worked for me – Mohit Rajan Mar 11 '16 at 8:39
  • 2
    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 – Sergiy Kolodyazhnyy Mar 11 '16 at 8:46
  • @Serg small correction systemd is available since 15.04 – EdiD Mar 11 '16 at 10:10
  • +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. – user37165 Mar 11 '16 at 13:33
3

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

  • 7
    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 – Sergiy Kolodyazhnyy Mar 11 '16 at 7:59
3

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

  • 2
    +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. – user37165 Mar 11 '16 at 13:17
  • 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. – user37165 Jun 15 '16 at 0:01
  • 1
    @clearkimura I'll look into it. Ping me if i forget – Sergiy Kolodyazhnyy Jun 15 '16 at 0:12
  • 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. – user37165 Jun 16 '16 at 19:17
  • This is a dreadful idea and clearly won't work on a server. – Ken Sharp Nov 22 '17 at 21:19
1

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.

0

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

  • 1
    E: Unable to locate package systemd-analyze – Ken Sharp Nov 22 '17 at 20:59
  • 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. – user535733 Nov 23 '17 at 2:23

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.