Skip to content

Instantly share code, notes, and snippets.

@BibMartin
Last active March 18, 2022 10:11
Show Gist options
  • Save BibMartin/42f8c429169620f24376f8ab8f30a5b3 to your computer and use it in GitHub Desktop.
Save BibMartin/42f8c429169620f24376f8ab8f30a5b3 to your computer and use it in GitHub Desktop.
Kill a process (and all it's children) based on a `ps -fA | grep` output
## Brutal shortcuts:
# Kill everything launched with "python registry.py"
kill -SIGTERM -$(ps aux | grep 'python registry.py' | awk '{print $2}')
# Same in a function
grepkill() { kill -SIGTERM -$(ps aux | grep $1 | awk '{print $2}'); }
# Restart a uvicorn server
git reset --hard ; kill -SIGTERM $(ps aux | grep 'uvicorn server:app' | grep -v "grep" | awk '{print $2}'); nohup uvicorn server:app --host 127.0.0.1 --port 8000 > server.log &
# Kill all docker instances of image "dask_worker"
docker stop $(docker ps | grep dask_worker | awk '{print $1}')^C
# Run a docker dask instance
nohup docker run --network=host -t dask_worker /opt/conda/envs/ulabenv/bin/dask-worker 172.30.1.53:8786 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment