how to execute more than one tar commands for parallel execution?

You can put all the tars in background like this:

tar cf - /ebs/uat/uatappl | gzip -c > /ebs/backup/uatappl.tar.gz &
tar cf - /ebs/uat/uatcomn | gzip -c > /ebs/backup/uatcomn.tar.gz &
tar cf - /ebs/uat/uatora | gzip -c > /ebs/backup/uatora.tar.gz &
tar cf - /ebs/uat/uatdata | gzip -c > /ebs/backup/uatdata.tar.gz &

But be aware you must have enough processor power and fast disk, otherwise the concurrency will make total execution longer than consecutive one


what's wrong with adding a & at the end of command line ?

tar cf - /ebs/uat/uatappl | gzip -c > /ebs/backup/uatappl.tar.gz &
tar cf - /ebs/uat/uatcomn | gzip -c > /ebs/backup/uatcomn.tar.gz &
tar cf - /ebs/uat/uatora | gzip -c > /ebs/backup/uatora.tar.gz &
tar cf - /ebs/uat/uatdata | gzip -c > /ebs/backup/uatdata.tar.gz &

wait

wait will wait for job to finish.


You can use GNU parallel, which is a tool for executing jobs in parallel. I've tested the below, and I believe this one-liner would work:

ls -1 /ebs/uat | parallel 'tar cf - /ebs/uat/{} | gzip -c > /ebs/backup/{}.tar.gz'

The webpage is here: https://www.gnu.org/software/parallel/, and a quick google appears to suggest there are solaris packages available, so you may not even have to manually install it.

Tags:

Solaris

Tar