Need help on Unix

Posted on 2012-08-27
Last Modified: 2012-09-02
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]$ ./
./ 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 :

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

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]$ ./
./ 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
Question by:sam_2012
    LVL 37

    Assisted Solution

    by:Gerwin Jansen
    Can you try defining a TMPDIR variable? Something like this:

    export TMPDIR=~
    LVL 40

    Assisted Solution

    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
    LVL 37

    Assisted Solution

    by:Gerwin Jansen
    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.
    LVL 19

    Assisted Solution

    You need to sort out / being 100% first or your going to be in a bit of bother.
    LVL 37

    Assisted Solution

    by:Gerwin Jansen
    I think /tmp is same as / in this case :)
    LVL 19

    Assisted Solution

    /tmp is under / yes, so / being 100% needs to be addressed first
    LVL 26

    Accepted Solution

    Have you considered:

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

    Open in new window


    Author Closing Comment

    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.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
    Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now