lorapop / code /slurm /lane_cpu.sh
bryan7264's picture
Add files using upload-large-folder tool
a8b5668 verified
Raw History Blame Contribute Delete
848 Bytes
#!/bin/bash
# MIT License, Bryan Cheng, 2026. Devel-CPU lane runner (D-029): keeps up to 2 jobs of this user in the devel partition by
# submitting the first non-comment line of slurm/cpu_queue.txt (a complete sbatch command); logs to slurm/cpu_queue.done.
cd /home/bjc75/other/finetuning
Q=slurm/cpu_queue.txt
while true; do
if [ "$(squeue -u bjc75 -h -p devel -o %i | wc -l)" -lt 2 ]; then
line=$(grep -v '^[[:space:]]*#' $Q | grep -m1 .)
if [ -z "$line" ]; then echo "$(date) queue empty"; exit 0; fi
out=$(bash -c "$line" 2>&1 | tail -1)
echo "$(date) | $line | $out" >> slurm/cpu_queue.done
if echo "$out" | grep -q "Submitted batch job"; then
grep -vxF -- "$line" $Q > $Q.tmp; mv $Q.tmp $Q; echo "$(date) submitted: $out"
else
echo "$(date) FAILED: $line -> $out"; sleep 600
fi
fi
sleep 120
done