K shell /tmp/sh$$.* files problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting K shell /tmp/sh$$.* files problem
# 1  
Old 10-28-2005
K shell /tmp/sh$$.* files problem

Hi,
I am encountring this problem from some time now...
ksh creates temp files /tmp/sh$$.* .
Sometimes if some of my shell script crashes or I kill it... these temp
files remain in the /tmp directory.
At some later time when some script gets the same PID it tries to
create files in the /tmp directory, It fails complaining that

sh$$.* : cannot create

Its a multi user unix system... so shell script may not overwrite files
created by other user.

Does any one have a solution to this problem....?

I dun want to do something like checking and deleting stray temp files
once in a while...

May be each user can have a separate TEMP directory...

Thanks
# 2  
Old 10-29-2005
Why don't you use the username as part of the name of the tempfile that is created? You can use $USER or $LOGNAME, whatever your system sets when the user logs in.
i.e.
instead of /tmp/sh$$.*, use /tmp/$USER.sh$$.* or /tmp/$LOGNAME.sh$$.*. This will create a file that can only be overwritten by that user as usernames are unique.
# 3  
Old 10-29-2005
Quote:
Originally Posted by blowtorch
Why don't you use the username as part of the name of the tempfile that is created? You can use $USER or $LOGNAME, whatever your system sets when the user logs in.
i.e.
instead of /tmp/sh$$.*, use /tmp/$USER.sh$$.* or /tmp/$LOGNAME.sh$$.*. This will create a file that can only be overwritten by that user as usernames are unique.
I am not creating these files.... the shell creates them... Ho can I force there name??
# 4  
Old 10-29-2005
To my knowledge, ksh does not create any temp files on its own. You may have some customized feature that is doing this. The best thing would be to find the source of these files and change the program that is creating them.
As a workaround, maybe you can schedule some sort of cron job that will remove the files from the /tmp filesystem every few minutes.
# 5  
Old 10-29-2005
ksh does indeed create temp of its own. They always go into /tmp and have names like sh$$.1. We have a few such files laying around. I have never seen a script fail like though. I kinda assumed that if sh$$.1 didn't work that the shell would go on to sh$$.2 and so on. But I'm not sure of that. I rarely do a "kill -9". I'm sure that I would see lots of sh$$.1 files laying around if I did "kill -9" more often. The OP rejected the solution I would use, so I have no remedy to suggest.
# 6  
Old 10-31-2005
Quote:
Originally Posted by blowtorch
To my knowledge, ksh does not create any temp files on its own. You may have some customized feature that is doing this. The best thing would be to find the source of these files and change the program that is creating them.
As a workaround, maybe you can schedule some sort of cron job that will remove the files from the /tmp filesystem every few minutes.

Shell creates a temporary file whenever it encounters a " << " . in the /tmp folder... If the file already exits in the location..and shell fails to overwrite (permissions) the sript fails....

As I told earlier I dun want a cron job to delete these files....

Is there any way I can change the path of creation for these tmp files... ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to find the GB files in /tmp directory in remote server

Hi, i need help on shell scripting. Main intention of the script is step 1: ssh to remote server Step 2: cd /tmp in remote server Step 3: in tmp i want to grep only files and directories which are in GB sizes All the servers list file is - tmpsrv.txt vi tmpsrv.txt ... (17 Replies)
Discussion started by: kumar85shiv
17 Replies

2. Red Hat

Can all files under /tmp be safely removed

I wanted to know whether all files under /tmp can be safely removed. I guess that /tmp may also have temporary files for applications currently being worked on, so at the most those applications may just shut down. I hope that my question is clear whether all files under /tmp can be safely... (5 Replies)
Discussion started by: RHCE
5 Replies

3. AIX

Unknown files in /tmp

I have a lot of files with the following names in /etc /tmp/<num>.mktcpip like /tmp/934030.mktcpip Anyone knows which process creates these files? (1 Reply)
Discussion started by: petervg
1 Replies

4. UNIX for Dummies Questions & Answers

ls or find files under /tmp/*

what is proper syntax to ls all files under /tmp/*, and wc -c ? (4 Replies)
Discussion started by: tjmannonline
4 Replies

5. AIX

what is creating the files in /tmp

How do I find what is creating these bunch of zero byte files under /tmp directory every few minutes. AIX - 5.3 TL05 # ls -l /tmp -rw-r--r-- 1 root system 0 Nov 05 16:54 n83n7a -rw-r--r-- 1 root system 0 Nov 05 16:54 ZO3S7a -rw-r--r-- 1 root system ... (3 Replies)
Discussion started by: mbak
3 Replies

6. AIX

problem with tmp

Hello everyone ! I get a box with aix 5.3 and I get the /tmp fs on 100 %. I get a free space to get more bigger my fs but send me a error message. I try to make more bigger with smitty chlv but It doesnt work. Then I try to reduce somethings on the /tmp fs but I cant get in on a... (4 Replies)
Discussion started by: lo-lp-kl
4 Replies

7. Shell Programming and Scripting

how to pin files to /tmp

Hi all, Am currently working on editing a startup script that need me to copy a certain file from cdrom to /tmp (its a live cd am working on)and mount if from there to certain place.. Now i know that nothing can be stored in /tmp permanently ,however mechanism to load the file to /tmp on... (19 Replies)
Discussion started by: wrapster
19 Replies

8. Solaris

How to save files in /tmp????

Hi all, I would like to know how to save files in /tmp... I was interested in knowing this because when ever i booted into solaris there would already be a few files present in /tmp.however any file that is freshly stored in would be lost on reboot... can anyone answer this pls!! (3 Replies)
Discussion started by: wrapster
3 Replies

9. AIX

set permission to files in /tmp

Trying to setup user to have the ability to delete any files (regardless of owner) in /tmp. I've tried almost everything... the permission on the folder is drwxrwxrwt 10 bin bin, and at one point I give all the possible permission (short of root) I can give to the user, and he still can't delete... (2 Replies)
Discussion started by: cchiang12
2 Replies

10. UNIX for Dummies Questions & Answers

monitoring /tmp and /var/tmp for suspicous activity

Hello, does anyone have a script that can check the contents of the /tmp directory and for example e-mail the directory content if anything other than session files are present? Maybe there are better ways to monitor suspicous /tmp and /var/tmp activity, if so I'm listening :) (1 Reply)
Discussion started by: jamesbond
1 Replies
Login or Register to Ask a Question