You are not logged in.
I know there is this thread with "SystemMaxUse option" in the object title which gives a way to clear /var/tmp of the undeleted systemd-private-* folders at shutdown, from ntpd service for example.
But I prefer to open a thread with a more appropriate subject title for that.
On my systemd init desktop computer, I have:
[berbae@arch64 ~]$ systemctl status systemd-tmpfiles-setup.service systemd-tmpfiles-clean.timer
systemd-tmpfiles-setup.service - Recreate Volatile Files and Directories
Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-setup.service; static)
Active: active (exited) since Fri, 05 Oct 2012 10:47:48 +0200; 1h 6min ago
Docs: man:tmpfiles.d(5)
Process: 293 ExecStart=/usr/bin/systemd-tmpfiles --create --remove (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/systemd-tmpfiles-setup.service
Oct 05 10:47:48 arch64 systemd[1]: Started Recreate Volatile Files and Directories.
systemd-tmpfiles-clean.timer - Daily Cleanup of Temporary Directories
Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.timer; static)
Active: active (waiting) since Fri, 05 Oct 2012 10:47:48 +0200; 1h 6min ago
Docs: man:tmpfiles.d(5)
systemd-tmpfiles-clean.timer uses the *.conf files in /usr/lib/tmpfiles.d
one of these files is tmp.conf which contains:
d /tmp 1777 root root 10d
d /var/tmp 1777 root root 30d
For /var/tmp there is an Age field which is 30 days.
So does that mean /var/tmp is automatically cleaned every months by default?
If this is the case, for one boot/shutdown every day, there will have at most 30 systemd-private folders for the ntpd service.
And as the folders are empty, they will not use much space on the disk.
Can someone confirms that I understand that matter well?
So, either there is nothing special to do to regularly clear the /var/tmp directory every month,
or the Age field can be reduced to a much frequent value.
Is this correct?
Last edited by berbae (2012-10-07 21:05:56)
Offline
This cleaning procedure is confirmed by the documentation:
[berbae@arch64 ~]$ grep -v '^#' /usr/lib/systemd/system/systemd-tmpfiles-clean.timer
[Unit]
Description=Daily Cleanup of Temporary Directories
Documentation=man:tmpfiles.d(5)
[Timer]
OnBootSec=15min
OnUnitActiveSec=1d
and
[berbae@arch64 ~]$ grep -v '^#' /usr/lib/systemd/system/systemd-tmpfiles-clean.service
[Unit]
Description=Cleanup of Temporary Directories
Documentation=man:tmpfiles.d(5)
DefaultDependencies=no
Wants=local-fs.target
After=systemd-readahead-collect.service systemd-readahead-replay.service local-fs.target
Before=sysinit.target shutdown.target
ConditionDirectoryNotEmpty=|/usr/lib/tmpfiles.d
ConditionDirectoryNotEmpty=|/usr/local/lib/tmpfiles.d
ConditionDirectoryNotEmpty=|/etc/tmpfiles.d
ConditionDirectoryNotEmpty=|/run/tmpfiles.d
[Service]
Type=oneshot
ExecStart=/usr/bin/systemd-tmpfiles --clean
IOSchedulingClass=idle
So the command 'systemd-tmpfiles --clean' is called 15 minutes after boot time, and then once a day if there is no shutdown.
From its manual:
--clean
If this option is passed all files and directories with an age parameter configured will be cleaned up.
So that confirms what I wrote in the preceding post.
Now to change the frequency of the cleanup, it should work copying /usr/lib/tmpfiles.d/tmp.conf to /etc/tmpfiles.d, and changing it to:
d /tmp 1777 root root 10d
d /var/tmp 1777 root root 7d
for a weekly /var/tmp/ cleanup instead of monthly.
Or still easier, let the default monthly cleanup.
Last edited by berbae (2012-10-07 09:01:28)
Offline
"d" in the beggining of every line means "Create a directory if it doesn't exist yet".
man tmpfiles.d for more information.
Offline
systemd-tmpfiles-clean.timer - Daily Cleanup of Temporary Directories Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.timer; static) Active: active (waiting) since Fri, 05 Oct 2012 10:47:48 +0200; 1h 6min ago Docs: man:tmpfiles.d(5)
systemd-tmpfiles-clean.timer uses the *.conf files in /usr/lib/tmpfiles.d
one of these files is tmp.conf which contains:d /tmp 1777 root root 10d d /var/tmp 1777 root root 30d
For /var/tmp there is an Age field which is 30 days.
So does that mean /var/tmp is automatically cleaned every months by default?
If this is the case, for one boot/shutdown every day, there will have at most 30 systemd-private folders for the ntpd service.
And as the folders are empty, they will not use much space on the disk.Can someone confirms that I understand that matter well?
That's correct. systemd will do a tmpflise cleanup at regular intervals (once a day? i forget). It will then delete any files which have not been accessed in the last 30 days (or whatever is configured).
Offline
Thanks guys, that's cleared things up a lot.
Sounds like sticking to systemd's default cleanup behaviour is okay.
Anything for a simpler life!
Offline
"d" in the beginning of every line means "Create a directory if it doesn't exist yet"
To clarify a little more, the same *.conf files are used to create, to remove and to clean directories and files, looking to the appropriate parameters in them.
The systemd-tmpfiles-setup.service calls at boot time:
/usr/bin/systemd-tmpfiles --create --remove
The systemd-tmpfiles-clean.service, controlled by systemd-tmpfiles-clean.timer, calls:
/usr/bin/systemd-tmpfiles --clean (it uses the Age parameter of d,D lines)
They all used the *.conf files found in, sorted in precedence order:
/etc/tmpfiles.d/*.conf
/run/tmpfiles.d/*.conf
/usr/lib/tmpfiles.d/*.conf
Offline
Yep, the default configuration works fine.
I used "touch --date" to modify the creation date of a folder in /var/tmp so that it would be older than a month and it got deleted 15min after my next reboot.
Offline
Thank you for the feedback birdflesh.
Personally I opted for a weekly cleanup of /var/tmp (30 useless folders from ntpd is too much for me).
But from that learning experience, I feel that this systemd-tmpfiles procedure is very flexible and configurable; I don't think that fine-tuning of creation, removal or cleanup of temporary directories and files was possible with the sysvinit initscripts. So it's a good point for systemd, in my present feeling about it.
Offline
Solved then? If so, you know what to do
Offline