When does /tmp get cleared?

That depends on your distribution. On some system, it’s deleted only when booted, others have cronjobs running deleting items older than n hours. On Ubuntu 14: using tmpreaper which gets called by /etc/cron.daily, configured via /etc/default/rcS and /etc/tmpreaper.conf. (Credits to this answer). On Ubuntu 16: using tmpfiles.d. (Credits to this answer). On other Debian-like systems: … Read more