Setting TMPDIR: Difference between revisions

From HPCwiki
Jump to navigation Jump to search
m (<source> to <pre> to fix code blocks)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Note: all nodes are partioned with a large /local (+- 400G), /tmp is much smaller!'''
'''Note: all nodes are partioned with a large /tmp (+- 400G).'''


Many programs require writing intermediary or temporary information. A process may even require writing to a temporary location without a user knowing it. For instance, the command <code>sort</code>, part of the <code>bash</code> toolkit, requires a lot of temporary file space when sorting large volumes of data. Often programs take the system default, which is usually <code>/tmp</code> on Linux systems. The <code>/tmp</code> partition is however often too limited in size and can get filled up. When this happens all users that require write access to <code>/tmp</code> will experience problems in running jobs, which can range from unexpected quitting of processes, to erroneous output.  
Many programs require writing intermediary or temporary information. A process may even require writing to a temporary location without a user knowing it. For instance, the command <code>sort</code>, part of the <code>bash</code> toolkit, requires a lot of temporary file space when sorting large volumes of data. Often programs take the system default, which is usually <code>/tmp</code> on Linux systems. The <code>/tmp</code> partition is however often too limited in size and can get filled up. When this happens all users that require write access to <code>/tmp</code> will experience problems in running jobs, which can range from unexpected quitting of processes, to erroneous output.  
Line 8: Line 8:


First, create a temporary directory on user designated space on on the 'scratch' partition:
First, create a temporary directory on user designated space on on the 'scratch' partition:
<source lang='bash'>
<pre>
mkdir /lustre/scratch/WUR/ABGC/[user]/tmp
mkdir /lustre/scratch/WUR/ABGC/[user]/tmp
</source>
</pre>


Set the <code>TMPDIR</code> variable to point at the custom directory in either <code>~/.bash_profile</code> or <code>~/.bashrc</code> using a command-line editor of choice (vi, emacs, nano, etc), adding the following line of code:
Set the <code>TMPDIR</code> variable to point at the custom directory in either <code>~/.bash_profile</code> or <code>~/.bashrc</code> using a command-line editor of choice (vi, emacs, nano, etc), adding the following line of code:
<source lang='bash'>
<pre>
export TMPDIR=/lustre/scratch/WUR/ABGC/[user]/tmp
export TMPDIR=/lustre/scratch/WUR/ABGC/[user]/tmp
</source>
</pre>


The temporary directory will be set to the custom location once you log in. For the current open terminal to set the new location immediately, without need to log out and in again:
The temporary directory will be set to the custom location once you log in. For the current open terminal to set the new location immediately, without need to log out and in again:
<source lang='bash'>
<pre>
source ~/.bash_profile
source ~/.bash_profile
</source>
</pre>
 
Note that certain (compiled) apps may in fact ignore the <code>TMPDIR</code> environment variable. These can include Java-apps and c++/g++ compiled apps.


== Setting custom temporary directory for Java applications ==
== Setting custom temporary directory for Java applications ==


Java applications often do not respond properly to re-setting of the system default by manipulating the <code>TMPDIR</code> environment variable. Java behaviour can be modified by setting the <code>_JAVA_OPTIONS</code> environment variable:
Java applications often do not respond properly to re-setting of the system default by manipulating the <code>TMPDIR</code> environment variable. Java behaviour can be modified by setting the <code>_JAVA_OPTIONS</code> environment variable:
<source lang='bash'>
<pre>
export _JAVA_OPTIONS=-Djava.io.tmpdir=/lustre/scratch/WUR/ABGC/[user]/tmp
export _JAVA_OPTIONS=-Djava.io.tmpdir=/lustre/scratch/WUR/ABGC/[user]/tmp
</source>
</pre>
Note that this does not - strictly speaking - manipulates a temporary directory specific environment variable; rather it sets a Java specific environment variable that allows to pass options to Java on runtime.
Note that this does not - strictly speaking - manipulates a temporary directory specific environment variable; rather it sets a Java specific environment variable that allows to pass options to Java on runtime.



Latest revision as of 15:45, 15 June 2023

Note: all nodes are partioned with a large /tmp (+- 400G).

Many programs require writing intermediary or temporary information. A process may even require writing to a temporary location without a user knowing it. For instance, the command sort, part of the bash toolkit, requires a lot of temporary file space when sorting large volumes of data. Often programs take the system default, which is usually /tmp on Linux systems. The /tmp partition is however often too limited in size and can get filled up. When this happens all users that require write access to /tmp will experience problems in running jobs, which can range from unexpected quitting of processes, to erroneous output.

Overriding the system default - works for many applications (but not all)

Users can set a custom temporary folder location by setting the TMPDIR environment variable. A custom temporary folder location is best placed in the 'scratch' space on the /lustre filesystem, because this will ensure periodic tidying up of the custom temporary directory thereby reducing the opportunity for very large temporary files that have gone unnoticed to remain on the filesystem. In addition, this is in line with protocols for the default system temporary directory /tmp as this directory is also periodically purged of older files.

First, create a temporary directory on user designated space on on the 'scratch' partition:

mkdir /lustre/scratch/WUR/ABGC/[user]/tmp

Set the TMPDIR variable to point at the custom directory in either ~/.bash_profile or ~/.bashrc using a command-line editor of choice (vi, emacs, nano, etc), adding the following line of code:

export TMPDIR=/lustre/scratch/WUR/ABGC/[user]/tmp

The temporary directory will be set to the custom location once you log in. For the current open terminal to set the new location immediately, without need to log out and in again:

source ~/.bash_profile

Note that certain (compiled) apps may in fact ignore the TMPDIR environment variable. These can include Java-apps and c++/g++ compiled apps.

Setting custom temporary directory for Java applications

Java applications often do not respond properly to re-setting of the system default by manipulating the TMPDIR environment variable. Java behaviour can be modified by setting the _JAVA_OPTIONS environment variable:

export _JAVA_OPTIONS=-Djava.io.tmpdir=/lustre/scratch/WUR/ABGC/[user]/tmp

Note that this does not - strictly speaking - manipulates a temporary directory specific environment variable; rather it sets a Java specific environment variable that allows to pass options to Java on runtime.

See also

Controling environment on the Agrogenomics cluster

External links