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 |