Find the answer to your Linux question:
Results 1 to 4 of 4
Hello all, Consider I am logged on a machine via SSH. I execute a process having "&" at the end from a shell - I run the process in background. ...
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    19

    can I bring to front a process started with &

    Hello all,
    Consider I am logged on a machine via SSH.
    I execute a process having "&" at the end from a shell - I run the process in background.
    Then I log off from the machine.

    I am just wondering if it is possible to bring that process to front after I log onto the machine again?
    I would like to check the output of my running process.

    Or is there any different approach to have a process running in background and to be able to view its output (i.e. printf)?

    Thank you in advance,
    Best regards

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Hi,

    look for a tool called GNU screen.
    Debian GNU/Linux -- You know you want it.

  3. #3
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    If you are in the same shell, you can use fg %{job_id} to bring a job back to the foreground. The jobs command will show you what processes are owned by your current shell and the jobid to use when bringing it back to the foreground. However, since you lose the shell after you log out, you will not be able to bring back to the foreground a job started in a previous session.

    The best way to do this, I think, is with screen. Use screen to open up a session and start the script. Then disconnect. When you re-connect, you can use screen to re-attach the session. Then, using the process described above, bring back to the foreground your running script.

  4. #4
    Just Joined!
    Join Date
    Jan 2008
    Posts
    19
    Quote Originally Posted by Thrillhouse View Post
    If you are in the same shell, you can use fg %{job_id} to bring a job back to the foreground. The jobs command will show you what processes are owned by your current shell and the jobid to use when bringing it back to the foreground. However, since you lose the shell after you log out, you will not be able to bring back to the foreground a job started in a previous session.

    The best way to do this, I think, is with screen. Use screen to open up a session and start the script. Then disconnect. When you re-connect, you can use screen to re-attach the session. Then, using the process described above, bring back to the foreground your running script.
    I guess I lose that possibility when I close the SSH connection.
    Anyway, GNU screen looks nice.

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...