The expansion of %A in sacct --expand-patterns is incorrect for job arrays. It expands to the unique id of the job and not to the array id. If the job is running, scontrol gives the actual path that the job is writing to. Example with a job array (JobId=4222747 ArrayJobId=4222555 ArrayTaskId=10): ``` sacct --job 4222555_10 --format=StdOut%200 --expand-patterns path/to/logs/4222747_10_0_log.out sacct --job 4222555_10 --json | jq -r '.jobs[0].stdout' path/to/logs/%A_%a_0_log.out sacct --job 4222555_10 --json | jq -r '.jobs[0].stdout_expanded' path/to/logs/4222747_10_0_log.out scontrol show job 4222555_10 | grep -i stdout StdOut=path/to/logs/4222555_10_0_log.out ``` Example with a regular job (JobId=4222523): ``` sacct --job 4222523 --format=StdOut%200 --expand-patterns path/to/logs/4222523_0_log.out sacct --job 4222523 --json | jq -r '.jobs[0].stdout' path/to/logs/%j_0_log.out sacct --job 4222523 --json | jq -r '.jobs[0].stdout_expanded' path/to/logs/4222523_0_log.out scontrol show job 4222523 | grep -i stdout path/to/logs/4222523_0_log.out ```