Add squeue in a Slurm job script - slurm

Normally I can check the job status by executing
squeue -u [userid]
at the command line after submitting the job. Is there a way to add this line in the job submission script so that the job status automatically shows up once the job is submitted?

Related

Check sbatch script of running job

When running an slurm job from an sbatch script, is there a command that lets me see what was in the sbatch script that I used to start this job?
For example sacct tells me I'm on SLURM_JOB_ID.3 and I would like to see how many job steps there will be in total.
I'm looking for a command that takes the job id and prints the sbatch script it is running.
You can use
scontrol write batch_script SLURM_JOB_ID
The above will display the submission script for job identified with jobid 12345
More info: https://slurm.schedmd.com/scontrol.html#OPT_write-batch_script

[slurm]How to check the job type on slurm ? batch or interactive

I want to determine whether a job on the slurm is a batch job or an interactive job.
It is possible to check the batch host with the following command, but is there a better way?
squeue -O "Name,BatchHost"
NAME EXEC_HOST
int login001
batch compute009
scontrol show job has a flag BatchFlag. The scontrol manpage says:
BatchFlag
Jobs submitted using the sbatch command have BatchFlag set to 1. Jobs submitted using other commands have BatchFlag set to 0.

SLURM how to know if a running job is a srun or a sbatch job?

I need to distinguish between batch and interactive job when are in RUNNING state.
I can't find with sact or stat a way to know if a job is a interactive session.
Did anyone already solved a similar problem?
You can use the batchflag formatting keyword in the squeue command to infer if a job has been submitted using the sbatch command.
$ squeue --Format=batchflag -u ${USER} --states=RUNNING
From the BatchFlag description in the scontrol help page:
Jobs submitted using the sbatch command have BatchFlag set to 1. Jobs submitted using other commands have BatchFlag set to 0.

pausing a shell script till previous command finishes

I have a shell script which has a qsub command follwed by other command which depend on the output of the qsub command. I have a shell script which looks like
qsub <my_jobs>
cat <some_files>
grep <some_pattern>
I want the qsub to finish running before the script goes to the cat command. I put "wait" after the qsub, but did not work.
Add "-sync y" to the qsub command line.
From the manual in: http://gridscheduler.sourceforge.net/htmlman/htmlman1/qsub.html
-sync y[es]|n[o]
-sync y causes qsub to wait for the job to complete
before exiting. If the job completes successfully,
qsub's exit code will be that of the completed job. If
the job fails to complete successfully, qsub will print
out a error message indicating why the job failed and
will have an exit code of 1. If qsub is interrupted,
e.g. with CTRL-C, before the job completes, the job
will be canceled.
With the -sync n option, qsub will exit with an exit
code of 0 as soon as the job is submitted successfully.
-sync n is default for qsub.

Need to know qsub completed job ids

I have a script that is posting bunch of qsub jobs. I can use following command to check job status.
qstat -u <user name>
I want to find out completed job ids. What command I need to use for that?

Resources