You are not logged in.
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
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.targetNow 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/AssetCacheNow I #systemctl enable local-shutdown.service
Last edited by Kilzool (2012-08-04 11:28:14)
Offline
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 0Sakura:-
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
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
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
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-2So 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.serviceLast edited by Kilzool (2012-08-16 20:01:10)
Offline
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
Glad you got it working.
Offline