Need to run the script in background, but having a problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to run the script in background, but having a problem
# 1  
Old 06-29-2010
Need to run the script in background, but having a problem

hi,
we have a script which runs for the whole day and whenever the job fails, will send an alert to the mailbox. My problem here is that i need to give the jobname dynamically which is not possible if we run the script in background. Pls help me with this.

Thanks
Ajay
# 2  
Old 06-29-2010
What do you mean by "give the jobname dynamically", and why isn't it possible if you run the script in the background?
# 3  
Old 06-29-2010
when i run the script, it shud ask me for a jobname and then the script will run until the job goes to success and send an email when it goes to Success.
i tried putting the jobname in a file, but when i run my script using nohup ./findstatuschange.sh & , it is getting stopped by SIGTTIN. I donno what it is
# 4  
Old 06-29-2010
SIGTTIN is "background process attempting read".
Something in your script is attempting to read from a terminal when there is no terminal in background.
Can you post the script?
# 5  
Old 06-30-2010
i dont have the script right now. Im at home and will post the script when i go to office tomorrow

---------- Post updated 06-30-10 at 12:12 AM ---------- Previous update was 06-29-10 at 12:12 PM ----------

Here's the code:
Code:
#!/bin/ksh
addr="ajay.akunuri@wellsfargoadvisors.com"
termAt="6:00:"
 
rm msg 1>&2 2>/dev/null
touch input.txt

if [ -s input.txt ]
then
:
else
mailx -s "Please enter the job name in input.txt and rerun!" "$addr"
exit 0
fi

 
while :
do
 
        date | grep "$termAt" > /dev/null 2>&1
        if [ $? -eq 0 ]
        then
                exit 0
        fi
        i=`cat input.txt`
        autorep -j "$i" | grep ' FA ' | awk '{print $1}' > msg
        autorep -j "$i" | grep ' SU ' | awk '{print $1}' > msg

# Send an email if the status of the job is changed
           
        if test -s msg 
        then 
        cat msg | mailx -s "ALERT! Status changed!" "$addr"
        rm input.txt msg
        exit 0
        fi
        sleep 120
done

I want to put the job name in input.txt and read it. But when i run the script in backgrnd using nohup ./Findstatuschange.sh & it is getting stopped by SIGTTIN. Pls help me with this

Last edited by ajayakunuri; 06-30-2010 at 04:49 AM..
# 6  
Old 06-30-2010
Quote:
mailx -s "Please enter the job name in input.txt and rerun!" "$addr"
I think that mailx is trying to read the message body from the terminal.

If you don't want anything in the message body and your spam filters will alow it:

Code:
echo ""|mailx -s "Please enter the job name in input.txt and rerun!" "$addr"

# 7  
Old 06-30-2010
Thank you.. It is working now Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to run a shell script in background without showing in the terminal?

Hi Guys, i am having a script which checks for ip address is pingable or not,when i execute this script in terminal it keeps on showing the pinging status of every ip address and it takes more time when i check for 100 ip address,How to do run a script in background without showing in the terminal... (4 Replies)
Discussion started by: Meeran Rizvi
4 Replies

2. Shell Programming and Scripting

Run command in background thru script

Dear All, Writing a script in which I want to run a command in background and keep it running even script is finished. I have tried like below, `truss -p <pid> >> & /tmp/log &` But doesnt work.. script goes running and nothing in log file. (7 Replies)
Discussion started by: Deei
7 Replies

3. Shell Programming and Scripting

Problem running a program/script in the background from a script

Hi all, I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion. My problem is sometimes the program takes... (5 Replies)
Discussion started by: newbie_01
5 Replies

4. Shell Programming and Scripting

shell script does not work if run in background

Dear All, I am trying to run a script in background like ./scriptname.sh & but when i try to run it in background it is giving me an error "syntax error at line 12: `(' unexpected" at the line 12, there is a function definition "function getFileList()". This script runs fine if i run on... (2 Replies)
Discussion started by: bilalghazi
2 Replies

5. UNIX for Dummies Questions & Answers

Run script in the background with a time interval

I have a script I want to run in the background, and I have looked it up but I am not exactly sure how to do. First of all to run it in the background do you have to put something in the script or is it just a command when you go to run it. I found this solution to it but once again I am not to... (2 Replies)
Discussion started by: mauler123
2 Replies

6. Shell Programming and Scripting

facing problem in starting a process in background using shell script.

hey all, i am working on sun solaris machine and i want to start a process in background using shell script (actually i wanna start tomcat server using shell script). please dont tell me that append a & at last because this is not working in the shell script. i have also used nohup and... (8 Replies)
Discussion started by: dtomar
8 Replies

7. Solaris

Best practice to run bash script in background

nohup /bin/bassh $HOME/scripts/test.sh > $HOME/log/test.log 2>&1 & nohup $HOME/scripts/test.sh > $HOME/log/test.log 2>&1 & Which is the good practice to run a script in background of above two ? does the first one will have any overhead on the system ? our system is SunOS 5.10... (2 Replies)
Discussion started by: mmasals
2 Replies

8. Shell Programming and Scripting

Is there away to run script in background within the script

Hello all i have csh script called test.csh , and i need to run it in the background so i do : test.csh & but i wander can i tell within the script source to run it in the background automatically , without giving the user to add the "&" when executing in the shell ? (1 Reply)
Discussion started by: umen
1 Replies

9. Shell Programming and Scripting

set schedule to run a script at background while logout

Hi, How can I run a script at 9:00am and 6:00pm everyday? Can I run it at background while I logout my account? Please help!! Many Thanks!! (1 Reply)
Discussion started by: happyv
1 Replies

10. Shell Programming and Scripting

how to run script at background

Hi all, I have a script like: echo Please input list file name: read listn for file in `cat $listn.txt` do send_file $file done normally, I will run the script like: :. resendfile Please input list filename: list1 #Then, the script will resend all file from the list1. However,... (4 Replies)
Discussion started by: happyv
4 Replies
Login or Register to Ask a Question