Xargs to run commands in parallel

I recently found out xargs had options to parallelize what it is working on. I finally had a good reason to try it. I’m processing log files for the last year. Each day is it’s own unique standalone task. My workstation is has 1 CPU with 6 cores that are hyperthreaded to give 12 logical cores. So… I asked xargs to run the processing script with 6 day log files and to run 10 processes in parallel. Zoom!

ls 2012*.tar | xargs -n 6 -P 10 process_log_files.py

Cool, I didn’t know that xargs can parallelize it’s work.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s