Repository to share code among the members of the SHM Working Group.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.4 KiB

  1. #!/bin/bash
  2. #################################################################
  3. # Script to find which Hydro jobs failed #
  4. # #
  5. # Loop over all slurm-<jobID>.out and print the failed jobs #
  6. # into a list. #
  7. # #
  8. # !Make sure you set properly the path to your .out files! #
  9. # !Check you set the correct name for your .out files! #
  10. #################################################################
  11. string="Finished." ## a succesfully completed hydro job will have this string in the last line of its output
  12. outfile="testlist.txt" ## file where we will list all the failed jobs
  13. if [[ -f "$outfile" ]]; then ## delete previous list of failed jobs
  14. rm $outfile
  15. fi
  16. for filename in ./slurm-*.out; do ## check all slurm-*.out files in the folder
  17. line=$(sed -n '$p' $filename) ## takes the last line of each file
  18. if [[ $line != *$string* ]]; then ## if line does NOT contain the specified string
  19. newname=$(echo $filename | sed 's#./slurm-##g' | sed 's#.out##g') ## strips the filename to the jobID
  20. echo "${newname}:: ${line}" ## also print jobID and the last line (reason for failure)
  21. echo $newname >> $outfile ## append jobID into the file
  22. fi
  23. done