Infrastructure Patterns

Parallel SSH across hosts — run uptime on 4 hosts concurrently
cat <<'EOF' | xargs -P4 -I{} ssh -o ConnectTimeout=5 {} uptime
192.168.1.10
192.168.1.11
192.168.1.12
192.168.1.13
EOF
Docker container cleanup — remove all stopped containers
docker ps -aq --filter status=exited | xargs -r docker rm
Docker dangling image cleanup — reclaim disk from untagged images
docker images -q --filter dangling=true | xargs -r docker rmi
kubectl pod restart — delete pods matching a label to trigger reschedule
kubectl get pods -l app=nginx -o name | xargs -n1 kubectl delete
Systemd service restart — restart a list of services
printf 'sshd\nnginx\npostgresql\n' | xargs -n1 sudo systemctl restart
Certificate expiry check across hosts — parallel TLS inspection
cat <<'EOF' | xargs -P4 -I{} sh -c 'echo "--- {} ---"; echo | openssl s_client -servername {} -connect {}:443 2>/dev/null | openssl x509 -noout -dates'
docs.domusdigitalis.dev
github.com
archlinux.org
EOF
Parallel pacman package info query
printf 'vim\nzsh\ngit\ntmux\n' | xargs -P4 -I{} pacman -Qi {}
Multi-repo git status — check all repos in a directory
ls -d ~/atelier/_bibliotheca/domus-*/ | xargs -I{} sh -c 'echo "=== {} ==="; git -C {} status --short'
Multi-repo git pull — parallel fetch across spokes
ls -d ~/atelier/_bibliotheca/domus-*/ | xargs -P4 -I{} git -C {} pull --ff-only
Bulk DNS lookup — parallel dig queries for a host list
cat <<'EOF' | xargs -P4 -I{} sh -c 'printf "%-30s %s\n" "{}" "$(dig +short {})"'
archlinux.org
github.com
docs.domusdigitalis.dev
cloudflare.com
EOF