Skip to main content

Most of us have multiple CPUs in our personal machines. I would also hope that your servers do too. If you're running an intensive command line process, running them in parallel will speed it up by paralleling the process.

Say you need to find a string in all of your log files. On any server that has multiple programs running there's a lot of log files to run though.

More Examples

# creates 4 processes (-P 4) each one looking at 10 files (-n 10)
find /var/logs -type f | xargs -P 4 -n 10 grep -H 'string-to-search'

# TIP: Calculate the number of cores for the `-P` argument
cat /proc/cpuinfo | grep processor | wc -l # Linux
sysctl -n hw.ncpu # Unix