public boolean killJob(String jobIdFile){
  List<String> jobIdFileContent=readFromFile(jobIdFile);
  if (jobIdFileContent.size() > 0) {
    String[] slurmCmd=new String[]{"scancel",jobIdFileContent.get(0)};
    return runProcess(null,slurmCmd,new StringBuilder(),new StringBuilder());
  }
 else {
    LOG.log(Level.SEVERE,"Failed to read the Slurm Job id from file: {0}",jobIdFile);
    return false;
  }
}

public boolean killJob ( String jobIdFile ) { List < String > jobIdFileContent = readFromFile ( jobIdFile ) ; if ( jobIdFileContent . size ( ) > 0 ) { String [ ] slurmCmd = new String [ ] { "scancel" , jobIdFileContent . get ( 0 ) } ; return runProcess ( null , slurmCmd , new StringBuilder ( ) , new StringBuilder ( ) ) ; } else { LOG . log ( Level . SEVERE , "Failed to read the Slurm Job id from file: {0}" , jobIdFile ) ; return false ; } }
cancel the slurm job by reading the jobid from the jobidfile . uses scancel command to cancel the job . the file contains a single line with the job id . this file is written by the slurm job script after the job is allocated .
