Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Environment variable TMPDIR kaput in sh,ksh ?

Status
Not open for further replies.

Hemo

Programmer
Apr 9, 2003
190
US

I frequently use << within shell scripts to read in commands and exec them. This has the habit of creating temporary files in the /tmp directory. I have some occasions where the script may not exit properly and leave strangling /tmp/sh* files around. Problem is when another user trys to run a script at a later time, pids may duplicate and the creation of the /tmp/sh* file fails because it already exists and is owned by a different user.

I've been accustomed to using:
TMPDIR=/another/dir;export TMPDIR

to have the shell use a specified tmp dir, but under SCO it seems the use of /tmp is hardcoded in /bin/sh and /bin/ksh ?

Can anyone verify/deny this or point me to another method to have the shell use a tmp directory of my choosing?
 
What you say seems to be true; perhaps the best thing would just be to add a find /tmp/sh* -mtime +7 -exec rm {} \; at the beginning of your scripts, or in a regular cron job.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top