The use of /var/tmp/ for File::tempDirectory

Shouldn’t it rather be /tmp/ instead of /var/tmp/ ?

Not that it matters very much, but the content of /var/tmp/ is not deleted during reboot, (while /tmp/ may be). Is that the case for the File::tempDirectory directories on macosx and windows as well?

Windows never ‘cleans’ its temporary directory, it expects programs to do that correctly themselves.

Okey, then I guess /var/tmp/ is correct. I did an exeption in my program though, so that on linux, /tmp/ is used instead of /var/tmp.

Okey, then I guess /var/tmp/ is correct. I did an exeption in my program though, so that on linux, /tmp/ is used instead of /var/tmp.[/quote]

You probably know this, but to avoid any misunderstandings, I also want to add that there’s no functionality provided by the system to automatically clean temporary files in linux. And just as in windows, its impossible to make a program that allways cleans up temporary files, no matter how well it is being designed. (kill -9 is all you need)

Theres also no rule that says that /tmp/ must be cleaned up during startup (in fact, usually, it isn’t), but it should be safe to assume that you can safely delete the files in /tmp/ during startup without screwing up anything. Therefore, it can be a better choice to use /tmp/ instead /var/tmp/.

I used to use /tmp, but changed to /var/tmp after doing a bit of googling about what the best places are for things like this. (Can’t remember where I read it or the reasoning behind it but it seemed to make sense at the time…)

/tmp is 90% of a time a in-Memory (tmpfs, ramfs) filesystem (thus gets cleaned on reboots, no scripts or commands delete any files there, they just disappear) and /var/tmp is on-disk filesystem.

Well /var/tmp is probably better for this purpose, as it’s the same as mac/windows temp folders

90%? What do you base that number on? Which distros are mounting /tmp/ as a ram-disk? In case anyone does that, I have to change my program back to using /var/tmp/ again, as its creating quite heavy files. :slight_smile:

well most of them, i can’t speak for all cause i haven’t tried them all
i don’t know if it’s “by default” in all cases but sys admins prefer /tmp to be very fast but limited in size. it’s a general rule not to create LARGE files there, and never rely on it to be storage for any important data.

i guess this explains all this.

i can’t speak for linux distros but Solaris (on witch i work) uses has /tmp i memory, i remeber using this in RedHat in my previous work. Most webservers that have php storing sessions in /tmp want to have that in-memory insetad on disk for speed enhancement. and many other situation where it’s a good idea (also a bad one when a developer forgets about this fact and fill /tmp with blobs of data, the system starts to swap like hell and that’s when i receive phone calls at night and am very pissed :)).

anyway ASSUME it’s in-memory and not permanent use /var/tmp for permanent storage. or better yet go with the latest trends and use some ENV variable to determine per-user TMP directory.

[quote=“atomix1040”]well most of them, i can’t speak for all cause i haven’t tried them all
i don’t know if it’s “by default” in all cases but sys admins prefer /tmp to be very fast but limited in size. it’s a general rule not to create LARGE files there, and never rely on it to be storage for any important data.

i guess this explains all this.

i can’t speak for linux distros but Solaris (on witch i work) uses has /tmp i memory, i remeber using this in RedHat in my previous work. Most webservers that have php storing sessions in /tmp want to have that in-memory insetad on disk for speed enhancement. and many other situation where it’s a good idea (also a bad one when a developer forgets about this fact and fill /tmp with blobs of data, the system starts to swap like hell and that’s when i receive phone calls at night and am very pissed :)).

anyway ASSUME it’s in-memory and not permanent use /var/tmp for permanent storage. or better yet go with the latest trends and use some ENV variable to determine per-user TMP directory.[/quote]

Yeah, I knew solaris used /tmp in ram, but I have quite large experience with linux, and haven’t seen it done by default by any distro. I know that many people do mount /tmp/ in ram though, I even did it myself a couple of years, but people who sets up /tmp/ to be in ram generally can handle situations where it gets full, so I don’t see that as a reason for me not to use /tmp/ for my program. (It would be a problem if inexperienced people got into big swapping problems, but I don’t think that will happen.)

i spoke from experience i dunno if any distros do that by default but i’m sure it’s definetly a common thing. anyway if you know the environment where the application will be running and your not going to give it to people than your ok. but if this app will be available for others keep in mind that it’s common to h ave /tmp in memory that’s all.

My FreeBSD box put /tmp on a drive, allocated to 4 gigs using a special filesystem.

Thanks for the info, but I already knew this. :?
If there is any common linux distro that ram-tmps by default, which I doubt, I would like to hear about it though.

like i wrote i don’t know if any distro has this by default i can imagine some might (livecd ones perhaps). there is so many right now and i always use Slackware.

sorry for the redundant advice.