nohup - sub job in script not executing until I exit


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers nohup - sub job in script not executing until I exit
# 1  
Old 08-15-2010
nohup - sub job in script not executing until I exit

My job is launched using this command: I'm at home and having VPN drops so I used nohup and background.

nohup perf_mon -c rating_4_multi,cfg &

The main script is PID 26119, and the sub task under it is 26118 which is not running - just sits there. 26119 runs forever but nothing else runs. I exit the session once and it appears to kill the 26119 task and trigger the sub task 26118 to run.

I tried doing that a second time and I got nothing so I sudo'd back in and exited twice - I ended up with a HUP command in the sub job log and get no execution. I exited twice because the first exit didn't appear to work. I might have been okay to do a single exit but it's too late now. Gotta rerun the job. (Takes several hours so this is really painful).

Code:
$ ps -lf
 F S      UID   PID  PPID   C PRI NI     ADDR     SZ    WCHAN    STIME TTY         TIME CMD
 0 O dgcprf1b 26119 26118  13  99 24        ?  19723          20:24:28 pts/23     93:36 perl /dgc/dgcprf1b/rel/server/bin/g
 0 S dgcprf1b 17272 17079   0  52 24        ?    214        ? 19:52:47 pts/23      0:00 sh -c vmstat -p 10 6000 >> vmstat.l
 0 S dgcprf1b 26118 17079   0  52 24        ?    214        ? 20:24:28 pts/23      0:00 sh -c getstats -nolog -deltamax -s
 0 S dgcprf1b 17263 17079   0  52 24        ?    214        ? 19:52:47 pts/23      0:00 sh -c uptime_iterator -s 10 -i 6000
 0 S dgcprf1b 17280 17269   0  52 24        ?    420        ? 19:52:47 pts/23      0:01 iostat -zT d 10 6000
 0 S dgcprf1b  7436     1   0  52 24        ?    410        ? 12:01:12 pts/23      2:51 top -s 10 -d 6000
 0 S dgcprf1b 17259 17079   0  52 24        ?    214        ? 19:52:47 pts/23      0:00 sh -c tail -f $ATA_DATA_SERVER_LOG/
 0 S dgcprf1b 17266 17079   0  52 24        ?    214        ? 19:52:47 pts/23      0:00 sh -c top -s 10 -d 6000 > top.log
 0 S dgcprf1b 23883  7959   0  50 20        ?    237        ? 18:25:59 pts/23      0:00 -ksh
 0 S dgcprf1b 17271 17259   0  52 24        ?    206        ? 19:52:47 pts/23      0:00 tail -f /dgc/dgcprf1b/data/server/l
 0 S dgcprf1b 17281 17272   0  52 24        ?    398        ? 19:52:47 pts/23      0:01 vmstat -p 10 6000
 0 S dgcprf1b 17274 17263   0  52 24        ?   2067        ? 19:52:47 pts/23      0:02 perl /dgc/dgcprf1b/work/perf_mon/bi
 0 S dgcprf1b 17269 17079   0  52 24        ?    214        ? 19:52:47 pts/23      0:00 sh -c iostat -zT d 10 6000 >> iosta
 0 S dgcprf1b  7441     1   0  52 24        ?    398        ? 12:01:12 pts/23      0:06 vmstat -p 10 6000
 0 S dgcprf1b  7959  7949   0  40 20        ?    469        ? 10:13:20 pts/23      0:00 -ksh
 0 S dgcprf1b 17265 17258   0  52 24        ?    214        ? 19:52:47 pts/23      0:00 tail -f /dgc/dgcprf1b/data/server/l
 0 S dgcprf1b 17258 17079   0  52 24        ?    214        ? 19:52:47 pts/23      0:00 sh -c tail -f $ATA_DATA_SERVER_LOG/
 0 S dgcprf1b 17278 17266   0  52 24        ?    410        ? 19:52:47 pts/23      0:37 top -s 10 -d 6000
 0 S dgcprf1b  7423     1   0  52 24        ?    212        ? 12:01:12 pts/23      0:01 tail -f /dgc/dgcprf1b/data/server/l
 0 S dgcprf1b 17079 23883   0  52 24        ?   1381        ? 19:52:02 pts/23      0:00 perl /dgc/dgcprf1b/work/perf_mon/bi
 0 O dgcprf1b 21840 23883   0  50 20        ?    238          21:58:05 pts/23      0:00 ps -lf
 0 S dgcprf1b  7430     1   0  52 24        ?    206        ? 12:01:12 pts/23      0:01 tail -f /dgc/dgcprf1b/data/server/l
 0 S dgcprf1b  7438     1   0  52 24        ?    420        ? 12:01:12 pts/23      0:07 iostat -zT d 10 6000



---------- Post updated at 10:36 PM ---------- Previous update was at 09:00 PM ----------

Set the job up again and exitted twice and got the "You have jobs running" message but the sub job didn't HUP. Sudo'd back in and exitted twice a couple times but can't get the sub job to launch this time. Might be because the sub job is not ready to run, and the exit is inneffective just yet. Mystifying....

Last edited by pludi; 08-15-2010 at 08:55 AM.. Reason: code tags, please...
# 2  
Old 08-15-2010
I can add some more - I launch the script using nohup and it executes a series of lines then stops at a particular line while that line executes.

This line calls a sub - script that gathers data for a log file. If I exit too soon during the execution of the sub script it sends a hup to the sub script and that sub script stops with no data in the log - say after an hour. I waited 5 hours before that to exit and the sub script was still hanging but it ended without a hup and put the log data in the log file.
This sub script runs for an undetermined amount of time - I have no idea how long it runs as I can't tell if it's doing anything or waiting or hanging.
If anyone can tell me how I can tell if the sub script is actually doing anything or just hanging that would be great. And tell me why the sub script would get a hup when I used nohup to launch the original script.

Also after the sub script stops, a few kill commands from the original script do execute. So why would the sub script stop working with a hup and the kill commands stil get executed?
# 3  
Old 08-17-2010
how about using GNU screen ?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to keep staying on remote server after executing a shell script with if then exit end statement?

i have a "if .. then exit end " in s shell script on remote servers. now the connection to the remote server got killed after i run this script on the remote servers. How do i run this script on remote hosts and still keep remote connections alive after executing the script. Thank you. (10 Replies)
Discussion started by: moonmonk
10 Replies

2. Shell Programming and Scripting

Executing 'exit' command from shell script

Hi, I am writing shell script to automate few use cases for CLI interface. We have CLI interface which has bunch of commands. I am trying to execute one of the commands 'exit' as part of automation to exit from CLI object (not from shell script) in my shell script. My intension is to execute... (4 Replies)
Discussion started by: Mahesh Desai
4 Replies

3. Shell Programming and Scripting

Help with finding the exit status of a 'nohup' command using 'PID'.

Hello All, I need to run a set of scripts, say 50 of them, parallely. I'm running these 50 scripts, from inside a script with the help of 'nohup' command. 1.The fifty scripts are stored in a separate file. 2.In a master script, i'm reading every line of the file through loop and executing... (4 Replies)
Discussion started by: SriRamKrish
4 Replies

4. UNIX for Dummies Questions & Answers

Execute shell script and if string found while executing then exit

Hi All, I have one shell script start.sh which executes another shell script test.sh something like below :test.sh -param1 -param2 In the test.sh there is one command for removing file:rm file1.bak I want whenever I execute start.sh, it will execute test.sh and if it finds string rm... (7 Replies)
Discussion started by: ORAI
7 Replies

5. Shell Programming and Scripting

Executing a script with nohup

Hi, Is there any way to achieve that my script should always execute like: nohup ./scriptname >nohup.out & even if i execute ./scriptname , it should be converted to nohup ./scriptname >nohup.out & and then execute. How i can achieve this? Thanks in advance (2 Replies)
Discussion started by: pandeesh
2 Replies

6. Shell Programming and Scripting

how do i execute nohup and background job inside the korn script for db2

load_cursor_stmt() { ls /db/admin/ddl/rmn01000/load_cursor*.sql|while read file do echo "${file}" `nohup db2 -tvf "$file" \&` done }Error: ------- /admin/ddl/rmn01000/load_cursor5.sql /db/admin/ddl/rmn01000/load_cursor6.sql + read file + echo... (3 Replies)
Discussion started by: Hangman2
3 Replies

7. Shell Programming and Scripting

Exit Shell Script with background job

Hi all, I am trying to exit a shell script (c shell) while invoking a job (service) that must run in the background: ...... /mydir/runservice & exit ...... There are downstream jobs and scripts that need to be run, but they all 'wait' for the script to exit. The script 'hangs' and... (3 Replies)
Discussion started by: CKT_newbie88
3 Replies

8. 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 test.sh ---------- 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

9. 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