The officially official Devuan Forum!

You are not logged in.

#1 2018-11-07 19:35:29

GNUser
Member
Registered: 2017-03-16
Posts: 417  

what deletes contents of /tmp directory? [SOLVED]

Some questions about /tmp:

1. Which utility or service is responsible for deleting the contents of /tmp?
2. Does the deletion happen at time of shutdown or boot?
3. Is there a way to change the deletion settings? (I cannot find /etc/tmp* or /etc/temp*)

Just wondering and trying to better understand things. I'm on Devuan ASCII if it matters.

Last edited by GNUser (2018-11-08 19:06:42)

Offline

#2 2018-11-07 19:49:07

GNUser
Member
Registered: 2017-03-16
Posts: 417  

Re: what deletes contents of /tmp directory? [SOLVED]

1. The checkroot-bootclean.sh service (service file is in /etc/init.d/, link in /etc/rcS.d/)
2. At boot
3. Via TMPTIME variable in /etc/default/rcS

Is this correct?

Last edited by GNUser (2018-11-08 13:48:26)

Offline

#3 2018-11-08 13:22:53

Geoff 42
Member
Registered: 2016-12-15
Posts: 187  

Re: what deletes contents of /tmp directory? [SOLVED]

Is /tmp guaranteed to be empty at Boot?

grep tmp /etc/rcS.d/S06checkroot.sh

returns nothing!

As it is fairly common to mount /tmp as a tmpfs, this will tend to leave it empty on a reboot.

Geoff

Offline

#4 2018-11-08 13:24:38

Geoff 42
Member
Registered: 2016-12-15
Posts: 187  

Re: what deletes contents of /tmp directory? [SOLVED]

Whoops! I got the wrong file!

grep tmp /etc/rcS.d/S08checkroot-bootclean.sh 
	# Clean /tmp, /run and /run/lock.  Remove the .clean files to
	rm -f /tmp/.clean /run/.clean /run/lock/.clean

Sorry!

Geoff

Offline

#5 2018-11-08 13:27:38

Geoff 42
Member
Registered: 2016-12-15
Posts: 187  

Re: what deletes contents of /tmp directory? [SOLVED]

The comment in /etc/rcS.d/S08checkroot-bootclean.sh seems to suggest that it is only the mount point that is cleaned out, before anything is mounted over the top of it.

Geoff

Offline

#6 2018-11-08 13:59:21

GNUser
Member
Registered: 2017-03-16
Posts: 417  

Re: what deletes contents of /tmp directory? [SOLVED]

Geoff, I was sloppy in post #2. What is in /etc/rcS.d/ is a link, obviously. The actual service file is /etc/init.d/checkroot-bootclean.sh. (I fixed post #2 now.)

First, looking inside the service file I see that it calls the clean_all function, which it sources from /lib/init/bootclean.sh

Then, looking inside /lib/init/bootclean.sh I see at the top that the purpose of its functions is to "Clean /tmp, /run and /var/lock if not mounted as tmpfs". The clean_all function calls clean_tmp

At the end of clean_tmp function definition there are two commands: One is to "remove all old files" and the other removes "all empty directories".

So if /tmp is not mounted as tmpfs, the checkroot-bootclean.sh service deletes old files and empty directories in /tmp but does not seem to guarantee that /tmp will be empty.

That's the story as I understand it, but there probably are some details that I'm missing.

Last edited by GNUser (2018-11-08 14:37:05)

Offline

#7 2018-11-08 14:33:02

Geoff 42
Member
Registered: 2016-12-15
Posts: 187  

Re: what deletes contents of /tmp directory? [SOLVED]

GNUser wrote:

Geoff, I was sloppy in post #2.

But not as sloppy as me! :-)

Geoff

Offline

#8 2018-11-08 14:35:01

GNUser
Member
Registered: 2017-03-16
Posts: 417  

Re: what deletes contents of /tmp directory? [SOLVED]

P.S. I've been doing some reading on /tmp and tmpfs and it seems that on Debian/Devuan /tmp is a normal directory by default. For /tmp to be a tmpfs, user has to add an entry in /etc/fstab.

I can confirm that on my ASCII installation /tmp is a regular directory (notice that /tmp does not appear in the last column):

bruno@thinkpad:~$ df -h | grep tmpfs
tmpfs           773M  1.2M  771M   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           2.0G   31M  1.9G   2% /run/shm
tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
tmpfs           772M   32K  772M   1% /run/user/1000

Offline

#9 2018-11-08 16:48:27

Geoff 42
Member
Registered: 2016-12-15
Posts: 187  

Re: what deletes contents of /tmp directory? [SOLVED]

While you can do it in /etc/fstab, you can also choose to use tmpfs for /tmp in /etc/default/tmpfs, where you can set RAMTMP=yes.

I think that the safest assumption about /tmp is that you cannot guarantee that anything in /tmp will survive a reboot, neither can you guarantee that it won't survive.

Geoff

Offline

#10 2018-11-08 17:00:20

GNUser
Member
Registered: 2017-03-16
Posts: 417  

Re: what deletes contents of /tmp directory? [SOLVED]

Geoff 42 wrote:

you can also choose to use tmpfs for /tmp in /etc/default/tmpfs, where you can set RAMTMP=yes.

I didn't know that. That's a very nice shortcut. Thank you.

Last edited by GNUser (2018-11-08 19:06:30)

Offline

Board footer