• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1254
  • Last Modified:

Need help on Unix

Hi ,

Iam writing a shell script to login into the database and fetch the value selected from dual. I have to execute the script using oracle login.  The problem iam facing is , my
/tmp folder is 100% full. So , in the shell script when iam redirecting the standard input to the here document , since the tmp folder is full, Iam getting the below error when I run the script

[root@localhost /home/scripts]$ ./sample1.sh
./sample1.sh: line 4: cannot create temp file for here document: No space left on device

So Modify the script , so that I redirect the here document to another folder It works when I run the script as a root user. But it fails with the same error when I run the script with the oracle user. below is the script :
sample1.sh

#!/bin/bash
sqlplus system/pass1234@localhost:1521/HR << /home/temp1 >> /home/sam
select 'hello' from dual;
/home/temp1

Shows the ouput of the df command , which reveals that the / folder is 100%  full.


[root@localhost /home/scripts]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             3.8G  3.6G     0 100% /
/dev/sda5              26G   16G  8.2G  67% /home
/dev/sda1              46M   18M   27M  40% /boot
tmpfs                 2.0G  940M  1.1G  48% /dev/shm

I also , tried by renaming the /tmp file to tmp_old and then creating a link  file called tmp that points to the different mount point. Again when I run teh script as root , no error , but when I run the script as oracle , I get the above mentioned error.
[oracle@localhost /home/scripts]$ ./sample1.sh
./sample1.sh: line 4: cannot create temp file for here document: No space left on device

My script needs to support this scenario wherein my /tmp folder is full . I need to given an option to the enduser to re-direct the here document to different folder incase the /tmp folder is full. Is there any environmental variable available to set the  temp folder to point some other mount when running the scripts from both root and oracle logins? Is there any work around for this issue.

thanks in advance
sam
0
sam_2012
Asked:
sam_2012
7 Solutions
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Can you try defining a TMPDIR variable? Something like this:

export TMPDIR=~
0
 
omarfaridCommented:
why your root filesystem (/) is 100% full? this could be the problem. try to remove some files or directories that you don't need.

Also, you could change temp dir by setting TEMPDIR env variable
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Seems the shell is always using /tmp for creating a small temporary file when using here documents. Remove about 1Kb from /tmp and try again.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
joolsCommented:
You need to sort out / being 100% first or your going to be in a bit of bother.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
I think /tmp is same as / in this case :)
0
 
joolsCommented:
/tmp is under / yes, so / being 100% needs to be addressed first
0
 
arober11Commented:
Have you considered:

#Delete any /tmp/ files older than a week old:
sudo find /tmp/  -mtime +7  -exec rm {} \;

Open in new window

0
 
sam_2012Author Commented:
Thanks all for the support .. It was really good answers. But I tried different work around for the issue i.e <br /> Check the size of the /tmp folder , if it is 100% full then create a link to point to mount point with more size .<br />This worked. I agree in real scenario , / folder cannot be 100% full.  But incase such scenario arises while running the program  , my requirement was that I had to make the above mentioned test and make it point to diff folder. After the script has run link will be broken and made to point to the original folder. I have used the ln command to create the link and unlink to remove the link.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now