Posted: . At: 8:43 AM. This was 1 year ago. Post ID: 17754
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Get information about your Linux boot easily.


Getting information about your Linux boot is very easy, this can show how fast your system can boot. Systemd is the secret, this system can provide a lot of very useful details.

Get the boot time of your Linux system.

┗━━━━━━━━━━┓ john@localhost ~/Documents
           ┗━━━━━━━━━━━━━╾ ╍▷ systemd-analyze 
Startup finished in 910ms (kernel) + 2.214s (initrd) + 12.590s (userspace) = 15.715s 
graphical.target reached after 12.583s in userspace

This shows how fast the system boots on an SSD with a modern Systemd powered system.

Get the actual time when the Linux system was actually booted. This could indeed be a very useful tip.

┗━━━━━━━━━━┓ john@localhost ~/Documents
           ┗━━━━━━━━━━━━━╾ ╍▷ awk '{print strftime("%c",systime()-$1)}' /proc/uptime
Fri 17 Mar 2023 06:05:02

Another way to get this information, use the uptime command.

┗━━━━━━━━━━┓ john@localhost ~/Documents
           ┗━━━━━━━━━━━━━╾ ╍▷ uptime -s
2023-03-17 06:05:03

it is also possible to see which services on your system are holding up the boot process of Linux. Use the systemd-analyze blame command to list all of this.

┗━━━━━━━━━━┓ john@localhost ~/Documents
           ┗━━━━━━━━━━━━━╾ ╍▷ systemd-analyze blame | head -n 16
16.927s dnf-makecache.service
 5.930s NetworkManager-wait-online.service
 3.761s plymouth-quit-wait.service
 1.516s dracut-initqueue.service
  958ms kdump.service
  699ms initrd-switch-root.service
  664ms systemd-udev-settle.service
  609ms firewalld.service
  467ms udisks2.service
  446ms tuned.service
  330ms polkit.service
  316ms accounts-daemon.service
  225ms ModemManager.service
  206ms microcode.service
  196ms logrotate.service
  191ms chronyd.service

Get the boot time and the uptime with this useful Python script.

import subprocess
from datetime import datetime, timedelta
 
def get_boot_time():
    output = subprocess.check_output(['uptime', '-s']).decode().strip()
    boot_time = datetime.fromisoformat(output)
    return boot_time
 
boot_time = get_boot_time()
print("Boot time    :", boot_time)
 
uptime = datetime.now() - boot_time
print("Uptime       :", uptime)

This is a very useful little script.

This is the output you will get. This a very useful way to get this pertinent info.

┗━━━━━━━━━━┓ john@localhost ~/Documents
           ┗━━━━━━━━━━━━━╾ ╍▷ python boot.py 
Boot time    : 2023-03-17 06:05:03
Uptime       : 2:35:54.749389

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.