nohup problem

Thread Tools Search this Thread
Operating Systems Linux Ubuntu nohup problem
# 1  
Old 09-04-2011
nohup problem

Hi All

I am struggling to get a process to run in the background on a Ubuntu Linux machine. I run: -

/home/brad > /usr/bin/nohup sudo /home/brad/spideroak/jsystem/runner/runAgent < /dev/null  & 
[1]    5611
/home/brad > /usr/bin/nohup: appending output to `nohup.out'

[1] + Stopped (SIGTTOU)        /usr/bin/nohup sudo /home/brad/spideroak/jsystem/runner/runAgent < /dev/null  &

/home/brad > exit
/home/brad > You have stopped jobs

The job kicks off ok but when I press enter I get the SIGTTOU message. Trying to exit warns me about the stopped jobs and if I continue to log out the job dies.

This is running under Korn shell on Ubuntu.

Can anyone tell me why I can't log out of the terminal without the job dying?

# 2  
Old 09-04-2011
The system is stopping your process with a SIGTTOU signal because while it's in the background it's trying to write to the terminal. If you want to avoid that, you should redirect stdout and stderr before backgrounding, or trap the signal and react appropriately (whatever that means for your task).

With regard to not being able to exit the shell without killing the job, have a look at the "disown" builtin in your shell's man page.

# 3  
Old 09-04-2011
Tried that too

Hi Alister

Thanks for the reply. Actually I have tried quite a variety of variations on this command: -

/usr/bin/nohup sudo /home/brad/spideroak/jsystem/runner/runAgent >/dev/null 2>&1 &

/usr/bin/nohup sudo /home/brad/spideroak/jsystem/runner/runAgent > ~/runAgent.out 2>~/runAgent.err  &

To mention but a few

I thought that nohup automatically redirected stderr and out to nohup.out anyway.

This really shouldn't be so hard Smilie

I'm wondering if there is some sort of job control mechanism interfering with this.

---------- Post updated at 04:01 PM ---------- Previous update was at 03:49 PM ----------

I should add that I can run a simple script to echo the date in the background using nohup and then exit without any problem. It still runs ok.

The runAgent script calls another wich eventually kicks of a Java process. Don't know if that is sigificant...
# 4  
Old 09-04-2011
Originally Posted by steadyonabix
I thought that nohup automatically redirected stderr and out to nohup.out anyway.
Duh. I forgot about that. You're correct of course. Still, SIGTTOU is the result of something trying to write to the terminal. Perhaps sudo is prompting for a password? Even if you (or nohup) have redirected stdin/stdout/stderr, sudo can still write to its controlling terminal.

Originally Posted by steadyonabix
I'm wondering if there is some sort of job control mechanism interfering with this.
Just because you're running a job in the background does not mean that an interactive shell will not kill it if the job is stopped and you insist on exiting the shell. You need to disown it if you want to exit the shell without killing the job. Of course, in this situation, that won't be of much help.


Last edited by alister; 09-04-2011 at 04:21 PM..
# 5  
Old 09-04-2011
run it via an at job.

echo "sudo /home/brad/spideroak/jsystem/runner/runAgent >~/runAgent.out 2>~/runAgent.err" | at now

# 6  
Old 09-04-2011
Hi Alister

Yeh, still haven't got to the bottom of it, think I'll sleep on it and see if I can come up with some inspiration... Smilie

I have seen some sudo failures in nohup.out where it is prompting for a password. Not sure why as it doesn't from the command line. Seems to write to it when I am trying to exit. Hmmm. Perhaps sudo is buffering......

The chain of events is I call a script I have set up in sudo file to run as root with no password.

That in turn calls another file that has several echos to stdout, (should be redirected?)

That file finally launches a java app. JSystem agent.

My sudo entry is currently: -

brad ALL = (root) NOPASSWD: /usr/bin/nohup /home/brad/spideroak/jsystem/runner/runAgent > ~/runAgent.out 2> ~/runAgent.err < /dev/null &

# 7  
Old 09-04-2011
I'm not a heavy sudo user, but wouldn't using sudo -b command <input >output 2>err be the right thing to use?

It will prompt for the password and then execute the command asynchronously (i.e. in the background if you think that way) and, in the wee bit of testing I did here, it seems to ignore hangup signals, so you can exit without taking the process down.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Nohup problem

Hi I need to execute about 1000 scp commands sequential , so I made "" - like this scp - rp ... scp - rp ... ............ scp - rp ... then I run nohup sh &The problem is: nohup process stopped when I closed session, or when the session expired,... Something wrong :(:(:( ... (4 Replies)
Discussion started by: bobochacha29
4 Replies

2. Shell Programming and Scripting

Saving nohup output to a file other than nohup.out

Shell : bash OS : Oracle Linux 6.4 I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts. For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to... (7 Replies)
Discussion started by: kraljic
7 Replies

3. Shell Programming and Scripting

Problem with nohup use in scripting

I am trying to execute following code: alarm_file_array="test1.alarms test2.alarms test3.alarms test4.alarms" for file in ${alarm_file_array} do nohup tail -f $file |awk 'NR>10' >> output.alarms 2>/dev/null & done Whenever it tries to execute nohup command it hangs because of the... (3 Replies)
Discussion started by: bhallarandeep
3 Replies

4. UNIX for Advanced & Expert Users

Problem on throwing sftp in nohup

Hi, but it is possible to effect a sftp in??? thanks thousand Germanico ---------- Post updated at 07:01 AM ---------- Previous update was at 05:51 AM ---------- Hi, but it is possible to effect a sftp in nohup mode??? (2 Replies)
Discussion started by: GERMANICO
2 Replies

5. Shell Programming and Scripting

Problem regarding nohup.out

There is a daemon which is constantly writing to this particular nohup.out file.This daemon can't be stopped. But the large size of this file is hampering the directory space.I want to write a script which will wait for 48 hours and then delete the contents of the file ( nohup.out ), but not the... (1 Reply)
Discussion started by: Gourav
1 Replies

6. Shell Programming and Scripting

Problem with nohup

Hello I am running this script #!/bin/ksh sqlplus -s username/password @temp.sql ----Here is my temp.sql set serveroutput on select instance_name from V$instance; exit When i run the script on the command runs fine...but when i run it using... (5 Replies)
Discussion started by: njafri
5 Replies

7. Shell Programming and Scripting

problem with exit while using nohup

Hi, I am kinda confused with this, am not sure what is happening i have a script say ---------- cat myfile | while read line do exit 2 done echo "out of loop" ----------- as it is evident, the exit should cause the script to terminate ,hence producing no output for the... (1 Reply)
Discussion started by: sumirmehta
1 Replies

8. UNIX for Dummies Questions & Answers

Problem with nohup command

Hello folks, I have got a script which telnets to different boxes and runs a certain script with 3 run time args. The line from the script which does it is: (sleep 1; echo $USERID ; sleep 1; echo $PASSWD ; sleep 1 ; echo y ; sleep 1 ; echo "\r" ; sleep 1 ; echo "cd $FILEPATH" ; sleep 1 ; sleep 1... (1 Reply)
Discussion started by: Rajat
1 Replies

9. Solaris

problem with nohup

While executing a ksh file with a input parameter in background like the following bash-2.03$nohup fil.ksh 4 & the nohup session is stopped. The same ksh file while executed like bash-2.03$fil.ksh 4 works fine. I am trying the above in Solaris 5.8 in bash shell. Please let me... (2 Replies)
Discussion started by: kkna
2 Replies

10. Shell Programming and Scripting

Problem executing nohup

I am trying to submit background jobs using the nohup command on a client system where my session is running under a "master shell" (BASH). If I try to nohup the actual job (ie: nohup MYJOB.BAT > MYJOB.LOG 2>&1 &) the command will fail with a return code of 126 and a "permission denied" message.... (0 Replies)
Discussion started by: christyw
0 Replies
Login or Register to Ask a Question