9

I am using an SSH client to connect to a Solaris server. I had a process running but my connection disconnected. I reconnected and can see the process running when I do ps -al. How can I bring this process to the 'foreground'? I want to see its output.

3
  • Wow your question so good. But i would like to know how you started job ?
    – Raja G
    Commented Feb 29, 2016 at 4:55
  • I started job by doing perl some_script.pl.
    – CJ7
    Commented Feb 29, 2016 at 4:58
  • Not sure it works on Solaris, but the question was answered here: unix.stackexchange.com/questions/31824/… Commented Feb 29, 2016 at 5:04

1 Answer 1

4

You can immediately re-activate your most recent backgrounded task by typing:

fg

If you have multiple backgrounded tasks, you can see the available jobs by typing:

jobs

You can then bring any of the tasks to the foreground by using the index in the first column with a percentage sign:

fg %

for example:

output of jobs command shows the process job number

[1]+  Stopped                 ssh username@some_host
[2]   Stopped                 ssh username@another_host

Bring any of the tasks to the foreground by using the index:

fg%2
4
  • How do you send a task to the background?
    – CJ7
    Commented Feb 29, 2016 at 9:51
  • @CJ7 - Using 'bg &' command
    – msc
    Commented Feb 29, 2016 at 10:25
  • 21
    This only works for processes started from the current shell, attached to the same TTY. The OP's question implies that he disconnected and reconnected from the host. The shell bg/fg commands probably won't be sufficient in this case.
    – Kenster
    Commented Feb 29, 2016 at 16:25
  • @Kenster yes this is my situation, then what to do ?
    – Freedo
    Commented Apr 30 at 10:52

Not the answer you're looking for? Browse other questions tagged .