0

The Scenario

I'm automating backups via a bash script. The script is executed via cron. The script archives directories recursively using tar, and then rsync's them to the remote host. Here is a sample:

...
for PATH in $DIRS
do
    ...
    tar -cpvzf $FFILE $PATH --exclude-from /tmp/excludes
    ...
    rsync -az --partial --rsync-path="sudo rsync" $FFILE mybackupserver:$REMOTEFILES
    ...
done
...

Each time tar or rsync is invoked, a new process (and therefore PID) is spawned for each one, obviously.

My Question

If I kill the process that started the script, will the child tar and rsync processes also be killed off immediately? Or will they run until completion, and no further ones will be spawned thereafter?

I'm reluctant to interrupt the tar or rsync processes mid-stream.

Thanks.

  • 1
    You might want to google for "nohup" - in short, what happens to the child process depends on how signal handling was set up when it was started (or changed at a later PIT) – Eugen Rieck Oct 10 '14 at 12:11
1

They will become orphan processes, becoming children of the script's parent. Usually they will become descendants of init.

| improve this answer | |
  • 1
    OK, so they do get interrupted? – Jongosi Oct 10 '14 at 12:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.