Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need help on Unix

Posted on 2012-08-27
8
Medium Priority
?
1,231 Views
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]$ ./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
Comment
Question by:sam_2012
8 Comments
 
LVL 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 390 total points
ID: 38337463
Can you try defining a TMPDIR variable? Something like this:

export TMPDIR=~
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 270 total points
ID: 38337496
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
 
LVL 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 390 total points
ID: 38338168
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Assisted Solution

by:jools
jools earned 120 total points
ID: 38344885
You need to sort out / being 100% first or your going to be in a bit of bother.
0
 
LVL 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 390 total points
ID: 38344985
I think /tmp is same as / in this case :)
0
 
LVL 19

Assisted Solution

by:jools
jools earned 120 total points
ID: 38345804
/tmp is under / yes, so / being 100% needs to be addressed first
0
 
LVL 26

Accepted Solution

by:
arober11 earned 720 total points
ID: 38347763
Have you considered:

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

Open in new window

0
 

Author Closing Comment

by:sam_2012
ID: 38359716
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

571 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