Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Background job not working as expected Post 302916296 by Scrutinizer on Monday 8th of September 2014 03:27:30 PM
Old 09-08-2014
I did the following test with bash:

Terminal 1:
Code:
$ while :; do sleep 1; done &
[1] 46950
$

Terminal 2:
Code:
$ shopt -s huponexit
$ while :; do sleep 1; done &
[1] 46988

Terminal 3:
Code:
$ ps -ef | grep -e 46950 -e 46988
  501 47102 43149   0  9:20PM ttys000    0:00.00 grep -e 46950 -e 46988
  501 46950 46940   0  9:19PM ttys001    0:00.03 -bash
  501 47100 46950   0  9:20PM ttys001    0:00.00 sleep 1
  501 46988 46944   0  9:19PM ttys002    0:00.02 -bash
  501 47099 46988   0  9:20PM ttys002    0:00.00 sleep 1

Terminal 1 & 2:
Code:
$ logout

[Process completed]

Terminal 3:
Code:
$ ps -ef | grep -e 46950 -e 46988
  501 46950     1   0  9:19PM ??         0:00.03 -bash
  501 47122 46950   0  9:20PM ??         0:00.00 sleep 1
  501 47124 43149   0  9:20PM ttys000    0:00.00 grep -e 46950 -e 46988


Last edited by Scrutinizer; 09-09-2014 at 01:55 PM..
These 3 Users Gave Thanks to Scrutinizer For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

background job

I try to run a script as background job. script: #!/usr/bin/csh /usr/bin/date +20%y-%m-%d > ~/datsql.txt If I start it I got this output: tac> ./datermitteln& 293 + Stopped (SIGTTOU) ./datermitteln& I insert the following line inside my script, but without any... (3 Replies)
Discussion started by: joerg
3 Replies

2. UNIX for Dummies Questions & Answers

Background job

Hiya, Recently I've run a few scripts in the foreground, but have realised later they should of been better nohup'd and placed in the background. I understand how to change a foreground job into a background one, but how would put the job into the nohup state? Thanks (1 Reply)
Discussion started by: rdbooth
1 Replies

3. UNIX for Dummies Questions & Answers

background job

on gnome i open a terminal and run wget http://soommmething & in the background. because wget shows me downloading progress percentage and download speed continuously, I exit the gnome-terminal after a while i want to see the download percentage but dont know how. my ps -u myname shows that... (3 Replies)
Discussion started by: babayeve
3 Replies

4. Shell Programming and Scripting

how to get background job to foreground

hi, i am just wondering that wen we give the following code we make a process run in background...can the viceversa be performed?i.e can this be made foreground again # sleep 75& 21751 # (4 Replies)
Discussion started by: sandilya
4 Replies

5. Shell Programming and Scripting

Cannot submit a background job

Hi all, I am currently facing a problem when i am submitting a script to run in the background to collect statistics round the clock on an AIX box. I don't have root authority nor can I set it in cron. So when i submit the job, it runs fine, but won't let me signoff. It prompts me that... (2 Replies)
Discussion started by: tansha
2 Replies

6. Linux

resume the suspended background job

Hi, I was running a job in background and because of some immediate work to be done on my machine, I stopped the background job. The real problem comes when I try to restart the same job in the background. To stop I used stop PID and to resume the same I use bg PID when I do this the... (2 Replies)
Discussion started by: baloo_mia
2 Replies

7. UNIX for Advanced & Expert Users

Background job when completed

Hello - I submitted one background job last night and it completed today morning.I want to know exact time the job completed. I submitted backgroung job like this nohup cp -Rp /opt/apps/prod/proddb/proddata . & I want to know when above job completed on UNIX server.Above command... (9 Replies)
Discussion started by: Mansoor8810
9 Replies

8. Shell Programming and Scripting

Background Job

Hello Everyody, Having a doubt. sort file1 & when we sent a job to the background it returns Job Number PID again if we want to ... (1 Reply)
Discussion started by: knroy10
1 Replies

9. Shell Programming and Scripting

Background job issue

How to bring a backgroud job say sample_script.sh to foreground (4 Replies)
Discussion started by: rafa_fed2
4 Replies
All times are GMT -4. The time now is 11:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy