How do I properly re-send a process to background after fg in Linux

3

2

In my remote terminal I have put in background the following running Linux process

dd if=/dev/sda3 | gzip -1 - | pv | ssh user@.rsync.net dd of=image.gzin

  • Ctrl+Z
  • bg
  • disown pid1 pid2 pid3 pid4 (4 pids since they are 4 commands in sequence where each pipes to the next one)

Then (without having left current SSH terminal session yet) I brought it in foreground with fg and I see it running.


1. How do I exit fg and send the process (job) back to its background ?

I am afraid that Ctrl+Z will make a second background or job for the already backgrounded process or Ctrl+C will end both fg screen and the process itself.

2. Also would it be possible to run fg for the same job again and bring it to foreground if I disconnect from remote terminal and reopen it after a while?

Cadmos

Posted 2018-06-05T12:32:29.717

Reputation: 182

You disown it and then you're able to fg? What shell is it? – Kamil Maciorowski – 2018-06-05T13:01:04.840

Yes I can fg it because I haven't still disconnected from the very same SSH session where I started the bg of the process. Second question has to do with that. | GNU bash, version 4.1.2(2)-release (x86_64-redhat-linux-gnu) – Cadmos – 2018-06-05T13:03:42.410

Strange. This is very different from Bash 4.3.48 and what I know about jobs. I disown a whole job (even if giving just one PID that belongs to the pipe of the job). After that it's no longer on the job list, so I cannot fg it. Your experience is different so there must be something I don't know. – Kamil Maciorowski – 2018-06-05T15:21:26.223

No answers