You are not logged in.

#1 2012-08-03 20:08:29

ricardofunke
Member
Registered: 2009-11-03
Posts: 46

[SOLVED] tmpfiles.d doesn't remove big directories?

I'm so confused about tmpfiles.d. I want to clean up two directories at every reboot. Here's my file:

[ricardofunke@funkenote ~]$ cat /etc/tmpfiles.d/tmp.conf
R /home/ricardofunke/tmp
d /home/ricardofunke/tmp 0700 ricardofunke ricardofunke - -

R /var/tmp
d /var/tmp 1777 root root - -

- If I create an empty file in these two directories, will be removed. Ok.
- If I create a directory with an empty file inside it, will be removed. Ok.
- If I copy a large directory into it (e.g apache tomcat), won't be removed. Why?!

Also, I tried to use rc.local and rc.local.shutdown (that was with initscripts-systemd) and it just don't work.

I just want to clean up these two directories at every shutdown/reboot, only that. How can I do that?

Last edited by ricardofunke (2012-08-16 19:57:18)

Offline

#2 2012-08-04 11:24:33

Kilzool
Member
From: Ireland
Registered: 2010-08-04
Posts: 232

Re: [SOLVED] tmpfiles.d doesn't remove big directories?

I will mention what I did (and maybe get some ideas on how to improve it or do it differently.)

I created a new service file:  /etc/systemd/system/local-shutdown.service

[Unit]
Description=local.shutdown service
After=basic.target
Before=shutdown.target

[Service]
Type=oneshot
ExecStart=/etc/local.shutdown
StandardInput=tty
RemainAfterExit=yes

[Install]
WantedBy=graphical.target

Now I created the executable script that is called by this service in /etc/
filename is  local.shutdown

#!/bin/bash
#
# local.shutdown: Local shutdown script.
#
rm -f /home/kilzool/.thumbnails/normal/*
rm -f /home/kilzool/.config/xfce4/panel/xfce4-notes-plugin-47-5.rc.*
rm -rf /home/kilzool/.adobe/Flash_Player/AssetCache

Now I #systemctl enable local-shutdown.service

Last edited by Kilzool (2012-08-04 11:28:14)

Offline

#3 2012-08-04 11:56:02

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,725
Website

Re: [SOLVED] tmpfiles.d doesn't remove big directories?

If you want the contents of those directories to be transient, I suggest making them into tmpfses.

e.g. in fstab

tmpfs /home/ricardofunke/tmp tmpfs defaults,uid=ricardofunke,gid=ricardofunke,mode=0700,size=10% 0 0
tmpfs /var/tmp tmpfs defaults,size=10% 0 0

Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#4 2012-08-10 18:36:12

ricardofunke
Member
Registered: 2009-11-03
Posts: 46

Re: [SOLVED] tmpfiles.d doesn't remove big directories?

Thank you @Kilzool, I'll do that.

Sorry @WorMzy, I don't want that, I want my /var/tmp to have 10G space and my tmpfs has just 2G. Every time I want to convert movies to DVD, for example, it requires at least 4.5G space free.

Also I use it a lot for testing purpose for my job and it requires a lot of space too. So tmpfs applies just for /tmp for me.

But, for /home/ricardofunke/tmp, it would suffice, but mount my home dir in fstab doesn't sound well for me...

Offline

#5 2012-08-13 19:17:37

ricardofunke
Member
Registered: 2009-11-03
Posts: 46

Re: [SOLVED] tmpfiles.d doesn't remove big directories?

Hi again,

I've tried @Kilzool solution but it doesn't work either...

Now it seems that the last update of initscripts have an integration with systemd and rc-local-shutdown.service was added as "static".

I have tried the @Kilzook solution with the script below and now it's in rc.local.shutdown, but it isn't running and my files still there after reboot.

Here's my code to remove the files:

#!/bin/bash
#
# /etc/rc.local.shutdown: Local shutdown script.
#

rm -rf /var/tmp && mkdir -m 1777 /var/tmp &
su - ricardofunke -c 'rm -rf tmp && mkdir tmp' &

suggestions?

Offline

#6 2012-08-16 19:47:48

Kilzool
Member
From: Ireland
Registered: 2010-08-04
Posts: 232

Re: [SOLVED] tmpfiles.d doesn't remove big directories?

First, I do not use initscripts.  That was removed from my system for complete systemd install.

systemd-188-2
systemd-arch-units-20120704-2-any
systemd-sysvcompat-188-2
systemd-tools-188-2

So I do not even know if your script is being executed.

-rwxr-xr-x 1 root root  /etc/local.shutdown*  (* = executable script)

-rw-r--r-- 1 root root  /etc/systemd/system/local-shutdown.service

Last edited by Kilzool (2012-08-16 20:01:10)

Offline

#7 2012-08-16 19:55:55

ricardofunke
Member
Registered: 2009-11-03
Posts: 46

Re: [SOLVED] tmpfiles.d doesn't remove big directories?

That's ok @kilzool, it's all my fault, my /var/tmp directory is a mounted partition and I was trying to remove it, of course it wasn't working...

But then, in trying to find what solution is best in that case, I found that tmpfs just works, because it uses swap partition in case of bigger files (not tested yet). So I just extend my swap to 10GB and mounted /var/tmp with tmpfs.

Thanks!

Offline

#8 2012-08-16 20:02:14

Kilzool
Member
From: Ireland
Registered: 2010-08-04
Posts: 232

Re: [SOLVED] tmpfiles.d doesn't remove big directories?

Glad you got it working.

Offline

Board footer

Powered by FluxBB