If none of the excellent options presented by the others work for you, one other possibilities is to invoke "scontrol show job NNNNN" (and maybe loop around various values of NNNNN from the outside) so you know that only *one* job output will be printed, and therefore you have less to parse/assume.

Yet another possibility is to use sacct instead of scontrol. At the cost of a uglier default and more complicated utilization, you have the advantage of being able to specify only the fields you care with the format AND of being able to run the query also one the jobs get out of the queue, when their records disappear from the scontrol output (the latter is a huge plus for me, but it could be useless and/or a distraction for your use case)

HTH

On Tue, Sep 22, 2026 at 9:16 PM Kevin Buckley (Pawsey) via slurm-users <slurm-users@lists.schedmd.com> wrote:
On Wednesday, September 23rd, 2026 at 05:04, Adam Novak via slurm-users <slurm-users@lists.schedmd.com> wrote:
>
> To illustrate the problem, I ran:
>
> sbatch --wrap "sleep 10" --comment="$(printf "\n\nJobID=12345\n\n")"
>
> And I found this in my `scontrol show job` output:
>
> JobId=38807436 JobName=wrap
> UserId=anovak1(30065) GroupId=prismuser(600) MCS_label=N/A
> Priority=4202 Nice=0 Account=standard QOS=normal
> JobState=RUNNING Reason=None Dependency=(null)
> Requeue=1 Restarts=0 BatchFlag=1 Reboot=0 ExitCode=0:0
> RunTime=00:00:09 TimeLimit=00:10:00 TimeMin=N/A
> SubmitTime=2026-09-22T13:47:15 EligibleTime=2026-09-22T13:47:15
> AccrueTime=2026-09-22T13:47:15
> StartTime=2026-09-22T13:47:17 EndTime=2026-09-22T13:57:17 Deadline=N/A
> SuspendTime=None SecsPreSuspend=0 LastSchedEval=2026-09-22T13:47:17 Scheduler=Backfill
> Partition=short AllocNode:Sid=phoenix:1297984
> ReqNodeList=(null) ExcNodeList=(null)
> NodeList=phoenix-06
> BatchHost=phoenix-06
> NumNodes=1 NumCPUs=1 NumTasks=1 CPUs/Task=1 ReqB:S:C:T=0:0:*:*
> TRES=cpu=1,mem=4000M,node=1,billing=1
> Socks/Node=* NtasksPerN:B:S:C=0:0:*:* CoreSpec=*
> MinCPUsNode=1 MinMemoryCPU=4000M MinTmpDiskNode=0
> Features=(null) DelayBoot=00:00:00
> OverSubscribe=OK Contiguous=0 Licenses=(null) Network=(null)
> Command=(null)
> WorkDir=/private/home/anovak1/workspace/cwltool
> Comment=
>
> JobID=12345
> StdErr=/private/home/anovak1/workspace/cwltool/slurm-38807436.out
> StdIn=/dev/null
> StdOut=/private/home/anovak1/workspace/cwltool/slurm-38807436.out
> Power=

Using slurm 25.11.7

$ scontrol show job --oneline <jobid>
JobId=<jobid>  JobName=wrap ...
... SubmitLine=sbatch --wrap sleep 10 -p <partition> -A <account> -N 1 -n 1 --comment=

JobID=12345 WorkDir=/path/to/work/dir Comment=

JobID=12345 StdErr= StdIn=/dev/null ...
$

so, if you have "SubmitLine=" in the output (which I don't see in
yours?), then you, or your parsing tools, should be able to "see"
both the CLI comment, the bit after "--comment=", and the "stored"
comment, the bit after "Comment=".

Still not as trivial as parsing the "marked-up" outputs in json or
yaml format, but at least you can identify a duplication.

--
slurm-users mailing list -- slurm-users@lists.schedmd.com
To unsubscribe send an email to slurm-users-leave@lists.schedmd.com