Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've run into an issue where an intel compiler generated program that I'm running with taskset has been putting its temporary files into the working directory instead of /tmp (defined by environment variable TMPDIR). If run by itself, it works correctly. If run with taskset (e.g.

taskset -c 0 <program>

Then it seems to completely ignore the TMPDIR environment variable. I then verified this by writing a quick bash script as follows:

contents of

echo $TMPDIR

When run by itself:

$ export TMPDIR=/tmp

When run through taskset:

$ export TMPDIR=/tmp
$ taskset -c 1

Another test. If I export the TMPDIR variable inside of my script and then use taskset to spawn a new process, it doesn't know about that variable:

export TMPDIR=/tmp
taskset -c 1 sh -c export

When run, the list of exported variables does not include TMPDIR. It works correctly with any other exported environment variable. If i diff the output of:



taskset -c 1 bash -c export

Then I see that there are 4 changes. The taskset spawned export doesn't have LD_LIBRARY_PATH, NLSPATH (intel compiler variable), SHLVL is 3 instead of 1, and TMPDIR is missing. Can anyone tell me why?

share|improve this question
Sorry, I guess it doesn't go without saying that TMPDIR is set in my environment but it is. It's been exported with export TMPDIR=/tmp – jonesy16 Aug 2 '13 at 15:09

I don't actually see evidence here that $TMPDIR is set in your environment. I can replicate the behavior you describe if I set TMPDIR as a local shell variable, like this:

$ TMPDIR=/tmp
$ taskset -c 0 sh -c 'echo TMPDIR: $TMPDIR'

Which yields:


But if I export TMPDIR to the environment, it works as one would expect:

$ TMPDIR=/tmp
$ export TMPDIR
$ taskset -c 0 sh -c 'echo TMPDIR: $TMPDIR'
TMPDIR: /tmp

Are you certain that TMPDIR is set in your environment? You can use the env command to dump your current environment:

$ env | grep TMPDIR

If I take your updated script:

export TMPDIR=/tmp
taskset -c 1 sh -c export

And run this on my CentOS system:

$ sh  | grep TMPDIR
export TMPDIR="/tmp"

It works as advertised. I'm not sure what's going on in your environment.

share|improve this answer
I tried your commands on my system (CENTOS 6.3) and I get TMPDIR: as the response. – jonesy16 Aug 2 '13 at 15:17
I'm running these commands on a CentOS 6.4 system. – larsks Aug 2 '13 at 15:18
Well then I'm more confused than ever .... It does seem to work correctly with any other variable name, just not TMPDIR. – jonesy16 Aug 2 '13 at 15:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.