Default tmp location

Learn More picture Learn More · Feb 6, 2013 · Viewed 8.4k times · Source

How to change default tmp location in Ubuntu?

I am using Ubuntu for my applications. I have seen that many APIs store their tmp files in /tmp folder.

In my Ubuntu, total space assigned to root is hardly 4 GB. Which is why I have to keep cleaning the /tmp folder to avoid disk space error.

Can I change /tmp to some other partition and allocate more space to it ?


UPDATE:

I have considered resizing partitions, but I can not risk data loss. Also, I can not risk impacting other applications which might have some data in /tmp folder.

As of now, I am using shell script to clean it every 10 minutes.

Answer

thkala picture thkala · Feb 6, 2013

Many applications look at the TMPDIR environment variable for the name of the temporary file directory, before defaulting to using /tmp. A simple partial solution to your problem (and possibly several others) could be to have a per-user temporary directory e.g. /home/$USER/tmp by setting the TMPDIR variable in the profile of each user.

That would move most temporary files to /home, with the added advantage that users would no longer be able to interfere with the temporary files of other users.