/tmp filling up

Does anyone know of a way to redirect the ksh default of processing data in /tmp to another file system or / something else?

My ksh script is parsing large DB files and it keeps filling up /tmp on the root disk.
I have a 1 Tb disk with most of its space.

How do I re-direct the /tmp ksh processes to that 1 Tb disk?

exporting TMPDIR=/path/to/whatever/ in the script or in a profile the script loads, before running the tmp-intensive processes, may do it.

If that doesn't work, it depends on what your system is, what your script is, and what program's creating these temp files.

its awk / gawk and sed that are doing it. Do you know how to redirect the output.
For instance sort -T wil redirect soreting out of /vat/tmp.
But i do not see anything in awk's man page like that.

I will try your method as soon as I can.

Thanks for the idea

I wasn't aware of awk/sed creating and using temp files on their own. Sort obviously needs a temp dir, but awk/sed hold data in memory. So it's probably the script that's redirecting their data into temporary files, not awk/sed themselves; options or environment vars fed into them would have no effect, the script decides where they go.

And unless they were extremely thoughtful in building that script, it might not obey TMPDIR.

Can we see the script?

It looks like it doesn't use much ram or swap (running topas).
Is there a way to attach the script. I would be happy to show you.
Its pretty big.

---------- Post updated at 02:47 PM ---------- Previous update was at 02:44 PM ----------

Here's the main part that is causing the /tmp to fill.
/tmp is : AIX 6.1 obviously since i referenced topas

MB-Blocks
/dev/hd3        2048.00   2043.71    1%       16     1% /tmp
#!/bin/ksh
set -x
#
var=5600
out=./check.out
LIST=/data/$var/tests/*.txt
COUNT=0
rg=
kg=
jg=
mailer1=chris.cheltenham@fisglobal.com
mailer2=cchelten@yahoo.com
rm -f ./*.out
##############################
#find duplicate lines field 2#
##############################
for i in /data/$var/tests/*.txt
do
dups ()
{
awk '/^01/ || /^05/ {if (i[$2]) { mf[$2]++; print $0; if (mf[$2] == 1) { print i[$2] } } i[$2] = $0}' |sort -k
2,2 -k 1,1
}

prse ()
{
sed -e 's%0\\\\\\%\:%g' |tr ':' '\n' | gawk -F'\' '$1==01{print $1,$4,$6,$2} $1==05{print $1,$4,$9}' $LIST
}
done
############################################################################################
dups | prse | grep -vi "eprprde|mtm|$var" |  while read aa bb cc dd
do
echo $dd >> ./check1.out
if [ $COUNT -eq 0 ]
        then
        rg=$bb
        kg=$aa
        jg=$cc
        fi

if [ $bb = $rg ]
                then
                ((COUNT=$COUNT+1))

                        if [ $aa -eq $kg ]
                        then
                        :
                        else
                        fld=`echo $dd | awk -F'^' '{print $2}' | awk -F'=' '{print $1}'`
                        dte=`echo $bb | cut -c11`
                        print Date/Time >> $out
                        print $dte >> $out
                        print $kg $bb $jg >> $out
                        print $aa $rg $fld >> $out
                        echo >> $out
                        fi
                else
                echo
                COUNT=1
                fi
        kg=$aa
        rg=$bb
        jg=$cc
done

---------- Post updated at 04:16 PM ---------- Previous update was at 02:47 PM ----------

the TMPDIR thing did not work by the way, good try though.

I see a sort -k in there. That could be doing it, and you know how to redirect that.

I will try it and let you know.I forgot i had that sort in there, Age is catching up wit me.