Solved Temporary directories in FreeBSD

Hello,

Is is safe to only use single directory for temporary files?
mv /var/tmp/* /tmp/
rm -rf /var/tmp
ln -s /tmp /var/tmp

Why do we have 2 temporary directory in FreeBSD?
 
/tmp in the old good days when disk space was limited, used to be a different partition thus making sure that the / will never run out of space. Many programs expect /var/tmp but assuming that you have enough disk space I don't see why not use one and symlink the other.
 
I tend to use them differently. I have tmpfs(5) mounted on /tmp. I expect files in /tmp/ to disappear after a reboot, whereas /var/tmp/ would still be there. So they both have a slightly different "temporary" usage.
 
Unless I'm mistaken, /tmp is just a dumping ground for any trivial process that requires it, while /var/tmp is used by vital system processes. Anything in the former can be dumped without much consequence, while the latter should be left alone. The system will clean it as necessary.
 
Yep, it's even explained in hier(7):
Code:
     /tmp/      temporary files that are not guaranteed to persist across sys-
                tem reboots
Underneath /var/:
Code:
               tmp/       temporary files that are kept between system
                           reboots

Having said that, I don't think there will be an issue if /tmp/ and /var/tmp are pointing to the same location.
 
/tmp
Code:
total 2792
-rw-------   1 root   wheel      2.2k Sep 23  2012 +CONTENTS20120923-51657-1m4dwi2-0
drwxrwxrwt   9 root   wheel       43k Jun 12 20:55 .
drwxr-xr-x  18 root   wheel      512B Jan 18 20:52 ..
drwxrwxrwt   2 root   wheel      512B Apr 10 10:47 .ICE-unix
drwxrwxrwt   2 root   wheel      512B Apr 10 10:47 .X11-unix
drwxrwxrwt   2 root   wheel      512B Apr 10 10:47 .XIM-unix
drwxrwxrwt   2 root   wheel      512B Apr 10 10:47 .font-unix
-rw-r--r--   1 root   wheel        7B Mar 10  2014 .munin-node.version
drwxrwxr-x   2 root   operator   512B Apr 10 10:48 .snap
-rw-------   1 www    wheel        0B Jun 12 03:00 apr04gnX2
-rw-------   1 www    wheel        0B Jun 12 03:00 apr39qhu1
-rw-------   1 www    wheel        0B Apr 10 03:00 aprc0KvTS
-rw-------   1 www    wheel        0B Apr 10 03:00 aprs8BbHU
srwxr-xr-x   1 root   wheel        0B Feb  1 17:53 conftest46802
-rw-r-----   1 www    wheel        0B May  3  2013 global.dir
-rw-r-----   1 www    wheel        0B May  3  2013 global.pag
-rw-r-----   1 www    wheel        0B May  3  2013 ip.dir
-rw-r-----   1 www    wheel        0B May  3  2013 ip.pag
-rw-------   1 root   wheel       39k Oct  4  2013 mergemaster.mtree.8iunIXKp
srwxrwxrwx   1 mysql  wheel        0B Apr 27 15:21 mysql.sock
drwxr-xr-x   2 www    wheel      512B Aug 10  2013 owncloud-52056abc3503d
drwxr-xr-x   3 root   wheel      512B Dec  1  2012 screens
-rw-------   1 www    wheel       34B Jun 12 12:59 sess_00p8eqaebfmg8sdfu6blr30pi4
-rw-------   1 www    wheel       34B Jun  9 16:29 sess_01l3pfa03e81lg2r8a8lchm7m5
-rw-------   1 www    wheel       34B Jun  7 22:35 sess_02i93ftoa6q5t9vp6o408g8j03
-rw-------   1 www    wheel       34B Jun  7 15:42 sess_07ev0ca9phucqj0bnj7j2cnsi5
..........
Note that many of them have been there for ages. The system has uptime: 63 days

/var/tmp/
Code:
total 4
drwxrwxrwt  2 root  wheel  512 May 20 13:50 vi.recover/
 
Back
Top