Tom
Tom

Reputation: 1263

rsync - how do I run commands 1 after another?

I want to run multiple commands. They don't need to run at the same time. Just run command 1, then command 2, etc.

rsync -az -P live/ test1/
rsync -az -P live/ test2/

Is there a way to do this without waiting for the first command to finish and then entering the second command?

Upvotes: 0

Views: 377

Answers (2)

Oliver-H-Miller
Oliver-H-Miller

Reputation: 451

Easy,

rsync -az -P live/ test1/; rsync -az -P live/ test2/

This will run test1 wait, then run test2.

Upvotes: 1

Nick Bull
Nick Bull

Reputation: 9866

Run them as background processes using &:

rsync -az -P live/ test1/ &
rsync -az -P live/ test2/ &

They are now running in the background! Should output something like:

[4] 9434

for each, where

  • [4] is used to get the process back to the foreground using fg 4 (i.e., running in the foreground in the shell); press CTRL+Z to pause it. Then to resume and start again in the background using bg 4.
  • 9434 is the PID.

Upvotes: 0

Related Questions