Showing posts with label xargs. Show all posts
Showing posts with label xargs. Show all posts

Wednesday, July 20, 2016

TIP: kill service on port in macOS

Example: Postgres, which runs on port 5432:

lsof -Pn | awk '/:5432..LISTEN/ {print $2}' | xargs -t kill

Does anyone know if Brew or something has the equivalent of good old Linux fuser -k 5432 ?

Thursday, March 24, 2016

UPDATED: quickly download lots of Python packages

This trick downloads Python packages up to 9x faster than normal:

egrep -o '^([A-Za-z].*==[^ ]+)' requirements.txt | xargs -n1 -P9 pip download

After things are downloaded, actually build and install the packages:

pip install -r requirements.txt

EDIT: original code gave `egrep: Invalid range end` -- fixed. Also added "-n1" to xargs so it'll download in parallel, vs sequentially.