how to automatically clean /tmp

Doug H. fedoraproject.org at wombatz.com
Wed Jan 27 19:50:07 UTC 2016


On Wed, 2016-01-27 at 20:29 +0100, Walter Cazzola wrote:
> Dear Linux Experts,
> 
> I've recently passed from Fedora 20 to Fedora 23 on my laptop.
> 
> I've a separate partition for /tmp that I'm used to see it wiped out
> at
> any reboot on my previous installation but now this is never wiped
> out.
> 
> This is a real partition:
> 
>    /dev/sda10       5029504   1154204   3596772  25% /tmp
> 
> whereas previously it was a tmpfs partition. I've read on the web
> that
> after Fedora 20 the tmpfs has been dropped in favor of real partition
> but I was expecting anacron/cron entry that wipe the content of the
> partition at boot but my system doesn't have any.
> 
> It is also difficult to create my own anacron/cron entry because this
> should take effect before the system starts and create its temp
> files/sockets in there.
> 
> I'm also puzzled because I also have a couple of tmpfs partitions:
> 
>    tmpfs            1633640         0   1633640   0% /run/user/989
>    tmpfs            1633640        16   1633624   1% /run/user/526
> 
> that I don't what they are for and if I can (and how) rid of them.
> 
> Probably I could add an entry like this
>    tmpfs                   /tmp            tmpfs           rw,seclabe
> l 0 0
> 
> in /etc/fstab but this would means a waste of the space I currently
> have
> reserved for /tmp (4Gb not much but I would prefer to use them).
> 
> So there is a way to wipe out the /tmp partition before it has been
> mounted and the system creates its files and use the current
> partition
> for it?


I did a fully default install in a Virtualbox using:
Fedora-Workstation-netinst-x86_64-23.iso

That install did use tmpfs for /tmp as seen below.

[root at localhost temp03]# df
Filesystem              1K-blocks    Used Available Use% Mounted on
devtmpfs                  1014436       0   1014436   0% /dev
tmpfs                     1024720     308   1024412   1% /dev/shm
tmpfs                     1024720    1184   1023536   1% /run
tmpfs                     1024720       0   1024720   0% /sys/fs/cgroup
/dev/mapper/fedora-root  10504444 5544500   4403300  56% /
tmpfs                     1024720      48   1024672   1% /tmp
/dev/sda1                  487652  243549    214407  54% /boot
tmpfs                      204944      36    204908   1% /run/user/1000
[root at localhost temp03]# uname -a
Linux localhost.localdomain 4.2.8-300.fc23.x86_64 #1 SMP Tue Dec 15
16:49:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root at localhost temp03]# cat /etc/fedora-release 
Fedora release 23 (Twenty Three)


If tmpfs is still the standard then that should explain why it is not
cleaning it.  As for how to run a shutdown version of rc.local it looks
like it is pretty well expained in the first few hits using:

fedora run script at shutdown

Looks like you just create your own script (could call it
rc.local.shutdown) and wrap it into a new systemd service.


-- 
Doug H.


More information about the users mailing list