Bash scripts for managing safe nodes on Linux

  • Cap the number of running nodes while you are starting nodes.

Obviously not so good when you are using safenode-manager or launchpad, but works great with snnm. (As with anything using the kill command, test and review if this will work for you.)

Rocky 9.4, bash

TARGET=50   # allowed number of nodes running at any time
while true
do
  [ $(ps -A | grep safenode | wc -l) -gt "$TARGET" ] && kill $(ps -A | grep safenode | head -2 | grep -o "^[ ,0-9]*")
  ps -A | grep safenode | wc -l ; ps -A | grep safenode | grep def | wc -l
sleep 2
done