8

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?

4
  • 2
    Yo ucould just use the same command . It worked for me Mar 11, 2016 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 Mar 11, 2016 at 8:46
  • @Serg small correction systemd is available since 15.04
    – EdiD
    Mar 11, 2016 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, 2016 at 13:33

4 Answers 4

4

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

1
  • 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 Mar 11, 2016 at 7:59
4

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

6
  • 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, 2016 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, 2016 at 0:01
  • 1
    @clearkimura I'll look into it. Ping me if i forget Jun 15, 2016 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, 2016 at 19:17
  • This is a dreadful idea and clearly won't work on a server.
    – Ken Sharp
    Nov 22, 2017 at 21:19
1

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

2
  • 1
    E: Unable to locate package systemd-analyze
    – Ken Sharp
    Nov 22, 2017 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, 2017 at 2:23
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .