ubuntu(16.04)启动时间分析与apt-daily.service优化

启动时间查询

mingfeng@thinking:~$ systemd-analyze
Startup finished in 8.199s (kernel) + 7.865s (userspace) = 16.064s

各启动项消费的时间查询

mingfeng@thinking:~$ systemd-analyze blame 
          6.196s NetworkManager-wait-online.service
          1.069s mysql.service
          1.015s dev-sda2.device
           331ms apparmor.service
           301ms php7.0-fpm.service
           280ms accounts-daemon.service
           253ms ModemManager.service
           253ms systemd-udevd.service
           227ms networking.service
           207ms systemd-logind.service
           198ms console-setup.service
           192ms lightdm.service
           180ms systemd-cryptsetup@cryptswap1.service
...

关于apt-daily.service启动优化

apt-daily.service启动时间可能会占用很长的时间(如20秒左右),因为这个服务对系统的使用并无太大影响且你又不想等待立即使用系统,可以将此服务延后执行。
那么你需要设置一个服务器执行的计时器apt-daily.timer

mingfeng@thinking:~$ sudo systemctl edit apt-daily.timer

# apt-daily timer configuration override
[Timer]
OnBootSec=15min
OnUnitActiveSec=1d
AccuracySec=1h
RandomizedDelaySec=30min

重启观察结果,是不是变快了!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注