Gzip with all cores

User1 picture User1 · Dec 3, 2010 · Viewed 49.1k times · Source

I have a set of servers filled each with a bunch of files that can be gzipped. The servers all have different numbers of cores. How can I write a bash script to launch a gzip for each core and make sure the gzips are not zipping the same file?

Answer

David Yaw picture David Yaw · Dec 3, 2010

There is an implementation of gzip that is multithreaded, pigz. Since it is compressing one file on multiple threads, it should be able to read from disk more efficiently, compared to compressing multiple files at once.