A fan-out script hangs the box, and new SSH logins fail with `bash: fork: retry: Resource temporarily unavailable`.
AdvancedTroubleshootingTroubleshooting: tools, portability, permissions and environment
Answer
Likely causes → The user hit its process limit (ulimit -u / nproc, or the systemd TasksMax= of the user slice or service). A loop launched a background job per item with no concurrency limit (for h in $(cat hosts); do check "$h" & done over 5,000 hosts), or a function recursed by calling itself in a pipeline.
Diagnose →
ps -u deploy --no-headers | wc -l # from root or another user
ulimit -u; systemctl show user-1001.slice -p TasksMax -p TasksCurrent
ps -u deploy -o pid,ppid,args --sort=ppid | head -30 # find the parent spawning everything
Fix → Kill the process tree (pkill -u deploy -f fanout.sh, or systemctl stop the unit), then bound concurrency:
xargs -a hosts.txt -P 20 -n 1 ./check_host.sh # at most 20 at a time
# or in pure Bash:
for h in "${hosts[@]}"; do
(( $(jobs -rp | wc -l) >= 20 )) && wait -n
check_host "$h" &
done
wait
Prevent → Every fan-out has a hard concurrency cap; run batch jobs under systemd with TasksMax= so a runaway script cannot starve the host.
More on Troubleshooting: tools, portability, permissions and environment
On a Mac, `sed -i 's/replicas: 2/replicas: 3/' deploy.yaml` fails with `sed: 1: "deploy.yaml": extra characters at the end of d command`.BeginnerA cleanup script fails on a developer's Mac with `date: illegal option -- d`.BeginnerA script that works on Ubuntu fails in an Alpine-based CI image with `grep: unrecognized option: P`.IntermediateAn `awk` one-liner works on your RHEL box but fails on Ubuntu with `awk: line 1: function gensub never defined`.Intermediate`comm -23 expected.txt installed.txt` prints `comm: file 1 is not in sorted order`, even though both files were produced with `sort`.Intermediate`grep ERROR /var/log/app/app.log` prints only `grep: /var/log/app/app.log: binary file matches`.Beginner