How to use Pigz with Tar

Cam picture Cam · Apr 28, 2016 · Viewed 35.6k times · Source

So I am using pigz in tar with

tar --use-compress-program=pigz

and this works but it doesn't use all of my processors, and I'd like to make sure it's recursive (-r) and using (-9 compression level).

I read through Utilizing multi core for tar+gzip/bzip compression/decompression but it doesn't note anywhere to add additional commands in that format, and I couldn't find anything in the man page for either program for additional swithed.

Thanks, Cam

Answer

Amit.Sinha picture Amit.Sinha · Oct 6, 2016

Mark Adler's top voted answer on the SO link that you included in your question does provide a solution for specifying compression-level as well as number of processors to use:

tar cf - paths-to-archive | pigz -9 -p 32 > archive.tar.gz

See : https://stackoverflow.com/a/12320421