本文主要是介绍Ubuntu之systemd延时启动服务(六十七),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Ubuntu之systemd延时启动服务
1.linux查看启动时间
# systemd-analyze
Startup finished in 10.026s (firmware) + 3.578s (loader) + 3.124s (kernel) + 1min 30.350s (userspace) = 1min 47.079s
graphical.target reached after 14.855s in userspace
2.linux查看每个应用启动顺序和时间
# systemd-analyze blame
8.648s vboxdrv.service7.746s plymouth-quit-wait.service5.297s NetworkManager-wait-online.service3.185s snap.lxd.activate.service1.381s snap-nmap-2280.mount1.379s snap-anbox\x2dinstaller-24.mount1.307s snap-fast-4.mount1.298s snap-atom-282.mount1.295s snap-gtk2\x2dcommon\x2dthemes-13.mount1.258s dev-nvme0n1p2.device1.142s snap-lxd-20806.mount1.131s snap-docker-796.mount1.055s snap-vlc-2344.mount1.027s snapd.service992ms snap-core-11187.mount942ms snap-pdftk-9.mount892ms snap-hexyl-25.mount868ms snap-core20-1026.mount777ms snap-audacity-857.mount774ms snap-snapd-12159.mount
3.应用和服务启动时间火焰图
# systemd-analyze plot > jupiter.example.com-startup.svg
此图发现graphical.target图形服务是最后启动的,所以After在graphical.target之后启动.
4.列出active服务
# systemctlUNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executable File Formats File System Automount Point dev-fuse.device loaded activating tentative /dev/fuse sys-bus-pci-drivers-nvidia.device loaded active plugged /sys/bus/pci/drivers/nvidia sys-devices-pci0000:00-0000:00:02.0-drm-card0-card0\x2deDP\x2d1-intel_backlight.device loaded active plugged /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight sys-devices-pci0000:00-0000:00:14.0-usb1-1\x2d1-1\x2d1:1.0-net-enx00e04c3600fa.device loaded active plugged RTL8152 Fast Ethernet Adapter sys-devices-pci0000:00-0000:00:14.0-usb1-1\x2d14-1\x2d14:1.0-bluetooth-hci0-hci0:256.device loaded active plugged /sys/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0/bluetooth/hci0/hci0:256sys-devices-pci0000:00-0000:00:14.0-usb1-1\x2d14-1\x2d14:1.0-bluetooth-hci0.device loaded active plugged
5.列出启动失败服务
# systemctl --failedUNIT LOAD ACTIVE SUB DESCRIPTION
● ipmiutil_wdt.service loaded failed failed ipmiutil Watchdog Timer Service using cron
● vboxdrv.service loaded failed failed VirtualBox Linux kernel module
6.systemd延时启动test.service
# emacs /usr/lib/systemd/user/test.service
DefaultDependencies=no
Requires=dbus.service
#等待系统启动完成,再启动本服务
After=graphical.target[Service]
User=root
ExecStart=/usr/bin/test
Restart=always
RestartSec=1[Install]
#等待图形界面启动完成后,再安装
WantedBy=graphical.target
这篇关于Ubuntu之systemd延时启动服务(六十七)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!