In a previous post we detailed how to archive data "on-the-fly" from a local source to a remote destination, using the utilities tar
, ssh
, and cat
. Today, we'll add nohup to that pipeline so that it can continue uninterrupted, irrespective of your current connection's status (a broken SSH session, e.g.).
Here goes:
First, preface your pipeline with the nohup
command:
nohup tar --gzip --create --verbose --file - foobar | ssh foo@foobarserver "cat > /path/to/foobar/foobar.tgz"
Second, stop the command using the following keyboard combination:
CTRL+Z
Third, place this foreground process into the background with:
bg
.
You'll then receive output similar to the following in your shell:
PID 26935: completed
PID 8072: in progress (foobar.tgz)
.
Pay attention to the latter process ID (PID
), as that will be the number you'll reference when checking on the job's status using, e.g.: top -p 8072
. For an overview of jobs
, and background/foreground processes see this article from Red Hat.
Cheers.