how can i bring the backgroud process to foreground
Linux - EnterpriseThis forum is for all items relating to using Linux in the Enterprise.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
There are less than 24 hours left to vote in the 2011 LinuxQuestions.org Members Choice Awards. Click here to go to the polls. Vote now and make sure your voice is heard!
how can i bring the backgroud process to foreground
Hi,
I had started a script, which i want to run it in the background . It started suceessfully . Now i want to bring that same process to foregroud. How can i do it?
I used the following command to start it , as a background process.
nohup ./script&
if you don't need it, you should remove the nohup from your script, because it acts like a disown for the shell, and you won't be able to put the job in foreground if you don't own it...
to see the processes your current shell owns, just type "jobs", then to put in foreground a job it is as utcursh says : "fg %job_id"
in your case i advice you to just do a "./script&" unless you want the script to continue running after you closed your shell.
I want the script to continue running after i closed my shell.
"you should remove the nohup from your script, because it acts like a disown for the shell, and you won't be able to put the job in foreground if you don't own it... "
Then How can i start a script to run in background,(to be owned) and want to continue running after i closed my shell.
Thank you,
Yes , am used to screen and its usage in the past. Here , i need to know How can i start a script to run in background,(to be owned) and want to continue running after i closed my shell.
actually, i don't know how to do, since when you run a script (owned by your shell), can be in background ot not, it will receive a SIGHUP signal when you close your shell (which default action is to terminate the script).
The nohup app is there to make the shell to "disown" the script so that it won't receive this signal at shell termination. The fact that your script isn't owned by your shell doesn't allow your shell to consider it as a shell job, and so i don't think it is possible to put it in foreground of the shell...
the only walkthrough i see is to make your script handle the SIGHUP signal (by registering an appropriate handler, see "man signal" or "man sigaction" for more info), in order to make sure it won't quit after shell termination. In this situation you won't need the nohup application and so your script will still be owned by your shell, so you will be able to put it in foreground.
However, note that this is only true until your shell is alive (i don't know if it is possible to make a new shell re-own a script that was own by another shell...) : your script will still run after you close your shell, but it won't be sufficient to put it in foreground in another shell...
i hope this is understandable, cause i don't think my post is -_-'
so if you need explanations, don't hesitate!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.