alias sqx='for J in $(squeue -h -u $USER -o "%i"); do
printf "\n\nJob %s\n" "$J"
scontrol show job $J | grep -E "TresPerNode|Command"
sacct -j $J -o submitline -n -P
done'
This is a function to run multiple jobs in parallel, but with a max number of parallel processes. New jobs will be run only if some previous jobs end and free up resources.
Credit to GPT-4.
First declare the following function in bash
function wait_for_jobs() {
local num_jobs=$1
while true; do