systemd-tmpfiles-setup.service takes 59min 24.321s to boot

Extremly short version:

Ubuntu 18.04 takes 1h 6min 17.410s to startup/ boot. It seems that systemd-tmpfiles-setup.service takes 59min 24.321s and apt-daily-upgrade.service 4min 13.257s.

More specifically, when I run a specific bash/python script with a lot of open() and close(), the next time I boot Ubuntu it takes that long.

It seems that when I use $ sudo apt-get update , $ sudo apt-get upgrade , $ sudo apt-get dist-upgrade before I close the computer it takes much shorter time (about 3 min) to boot, almost normal ( by normal I mean around 1 min). Additionally tmp doesn’t seem to take a lot of space, so I didn’t try deleting it.

Is there something else or more targeted I could do?

The checks I did :

$   systemd-analyze  Startup finished in 5.752s (kernel) + 1h 6min 11.657s (userspace) = 1h 6min 17.410s 


$   systemd-analyze blame    59min 24.321s systemd-tmpfiles-setup.service     4min 13.257s apt-daily-upgrade.service     1min 55.790s apt-daily.service          22.109s plymouth-quit-wait.service          17.100s systemd-journal-flush.service          14.060s dev-sda5.device           9.434s NetworkManager-wait-online.service           7.650s apparmor.service           7.415s dev-loop16.device           6.926s dev-loop17.device           6.817s plymouth-read-write.service           6.687s dev-loop23.device           6.647s dev-loop6.device           6.572s dev-loop9.device           6.500s networkd-dispatcher.service           6.282s dev-loop21.device           6.210s dev-loop18.device           6.072s dev-loop19.device           6.042s dev-loop22.device           6.008s dev-loop14.device           5.913s dev-loop11.device           5.811s dev-loop8.device           5.236s snapd.service           4.965s dev-loop12.device           4.916s dev-loop7.device           4.848s dev-loop20.device           4.761s dev-loop15.device           4.663s dev-loop10.device           4.643s dev-loop5.device           4.624s dev-loop13.device           4.429s dev-loop2.device           3.962s dev-loop4.device           3.718s systemd-rfkill.service           3.518s NetworkManager.service           3.126s systemd-tmpfiles-clean.service           2.858s systemd-logind.service           2.816s dev-loop3.device           2.524s systemd-udevd.service           2.487s udisks2.service           2.474s thermald.service           2.470s dev-loop1.device           2.325s systemd-sysctl.service           2.124s dev-loop0.device           2.016s snap-core18-1074.mount           1.929s ModemManager.service           1.890s accounts-daemon.service           1.787s snap-core18-1066.mount           1.688s snap-code-13.mount           1.520s snap-gnome\x2d3\x2d28\x2d1804-71.mount           1.336s snap-gnome\x2dcharacters-292.mount           1.235s snap-gnome\x2d3\x2d26\x2d1604-88.mount           1.176s snap-sublime\x2dtext-58.mount           1.110s snap-gnome\x2d3\x2d28\x2d1804-67.mount           1.084s systemd-update-utmp.service           1.075s systemd-modules-load.service           1.052s snap-code-12.mount           1.035s fwupd.service           1.021s systemd-tmpfiles-setup-dev.service           1.013s snap-core-7270.mount            962ms motd-news.service            957ms networking.service            956ms snap-gnome\x2dcalculator-406.mount            951ms snap-sublime\x2dtext-67.mount            877ms snap-gtk\x2dcommon\x2dthemes-1198.mount            849ms gpu-manager.service            829ms grub-common.service            827ms snap-gnome\x2dcharacters-296.mount            810ms snap-gnome\x2dlogs-45.mount            796ms iio-sensor-proxy.service            793ms keyboard-setup.service            760ms snap-gnome\x2dsystem\x2dmonitor-100.mount            746ms packagekit.service            740ms dns-clean.service            722ms plymouth-start.service            717ms wpa_supplicant.service            681ms systemd-backlight@backlight:intel_backlight.service            635ms snap-gimp-165.mount            632ms avahi-daemon.service            620ms swapfile.swap            618ms snap-gnome\x2d3\x2d26\x2d1604-90.mount            542ms snap-gnome\x2dsystem\x2dmonitor-95.mount            541ms console-setup.service            479ms colord.service            454ms ufw.service            445ms polkit.service            439ms systemd-journald.service            424ms systemd-random-seed.service            350ms snap-gimp-189.mount            337ms user@1000.service            334ms snap-gtk\x2dcommon\x2dthemes-1313.mount            321ms snap-gnome\x2dcalculator-260.mount            307ms rsyslog.service            306ms snap-gnome\x2dlogs-61.mount            276ms snapd.seeded.service            224ms sys-kernel-debug.mount            223ms kmod-static-nodes.service            203ms apport.service            195ms snap-core-7396.mount            185ms systemd-remount-fs.service            172ms upower.service            148ms gdm.service             75ms bolt.service             63ms systemd-udev-trigger.service             58ms dev-hugepages.mount             35ms systemd-resolved.service             35ms systemd-timesyncd.service             30ms speech-dispatcher.service             26ms bluetooth.service             24ms alsa-restore.service             16ms setvtrgb.service             12ms kerneloops.service             12ms ureadahead-stop.service              9ms systemd-update-utmp-runlevel.service              8ms pppd-dns.service              7ms dev-mqueue.mount              6ms rtkit-daemon.service              6ms systemd-user-sessions.service              2ms sys-fs-fuse-connections.mount              2ms sys-kernel-config.mount 


$   systemd-analyze critical-chain The time after the unit is active or started is printed after the "@" character. The time the unit takes to start is printed after the "+" character. @1h 15.288s └─ @1h 15.288s   └─snap-gnome\x2dcalculator-260.mount @5.932s +321ms     └─ @3.729s       └─systemd-tmpfiles-setup-dev.service @2.707s +1.021s         └─kmod-static-nodes.service @2.482s +223ms           └─systemd-journald.socket @2.480s             └─system.slice @2.480s               └─-.slice @2.451s