Distributions are different of course, but I'd expect temporary files to be managed automatically by the system out-of-the-box. They'd likely use either cron jobs or the systemd-tmpfiles-clean service. If you're worried about disk space, this is a useful command to take a look at how much space each root folder is taking:
du -hs /* | sort -h
To see if your system is using the systemd service for managing temporary files, you can just try:
systemctl status systemd-tmpfiles-clean
At the bottom you would see something like the following, which tells you when the service was last run:
systemd-tmpfiles-clean.service - Cleanup of Temporary Directories
Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.service; static; vendor preset: disabled)
Active: inactive (dead) since Wed 2018-07-18 15:43:36 IST; 18h ago
Process: 30495 ExecStart=/usr/bin/systemd-tmpfiles --clean (code=exited, status=0/SUCCESS)
Main PID: 30495 (code=exited, status=0/SUCCESS)
Jul 18 15:43:36 host-name systemd: Starting Cleanup of Temporary Directories...
Jul 18 15:43:36 host-name systemd: Started Cleanup of Temporary Directories.
Note that this service will exit as soon as it's done with the clean-up. A timer service is responsible for regularly triggering it. You can check it with:
systemctl status systemd-tmpfiles-clean.timer
And you should expect something like the following:
systemd-tmpfiles-clean.timer - Daily Cleanup of Temporary Directories
Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.timer; static; vendor preset: disabled)
Active: active (waiting) since Tue 2018-07-03 10:56:59 IST; 2 weeks 1 days ago
Jul 03 10:56:59 host-name systemd: Started Daily Cleanup of Temporary Directories.
Jul 03 10:56:59 host-name systemd: Starting Daily Cleanup of Temporary Directories.
If you look again at the actual service responsible for cleaning the files, you'll see that all it does is run:
So you could either run that command directly, or to do it properly, just do:
systemctl start systemd-tmpfiles-clean
Which will run the appropriate command for your system. However, you should be aware that this is not a "delete all temporary files now" command. There are several configuration files that control what actually gets deleted and when so that applications can individually configure their temporary files.
One place to look for generic handling of temporary files could be
/usr/lib/tmpfiles.d/tmp.conf which might have the following relevant lines:
# Clear tmp directories separately, to make them easier to override
v /tmp 1777 root root 10d
v /var/tmp 1777 root root 30d
You could change those to a shorter time, if your system keeps running out of space, for example, to:
v /tmp 1777 root root 12h
v /var/tmp 1777 root root 1d
To be sure of what you're doing, do
man tmpfiles.d to read the manual. Again, I have found the approach presented here to be relevant on a CentOS (RedHat based) and an Ubuntu system, but I don't know much about other distributions.