# BASH\_XTRACEFD error in batch job

**URL:** <https://cylc.discourse.group/t/bash-xtracefd-error-in-batch-job/1330>\
**Category:** Cylc Support\
**Created:** [July 14, 2026, 6:59pm UTC](https://cylc.discourse.group/t/bash-xtracefd-error-in-batch-job/1330 "2026-07-14T18:59:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bpabla50](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@bpabla50](https://cylc.discourse.group/u/bpabla50)\
**Post date:** [July 14, 2026, 6:59pm UTC](https://cylc.discourse.group/t/bash-xtracefd-error-in-batch-job/1330/1 "2026-07-14T18:59:50Z")

</div>

Hi  
I have a task running in batch mode, which is suddenly dying. I don’t think, it is timing out. Only error I found in job.err is :

```bash
/usr/bin/bash: BASH_XTRACEFD: 19: invalid value for trace file descriptor

```

what causes it? Is it can force to terminate job?

```ini
$ cylc vip --debug .

# flow.cylc:
...
   [[GEMMACH]]
      script = "$TASK_RUN_SCRIPT $TASK_CONFIG_FILE"
   [[get_emissions]]
      inherit = GEMMACH
      platform = my_frontend
      execution time limit = PT15M
      [[[directives]]]
         -l = select=1:ncpus=1:mem=2gb
         -q = development
      [[[environment]]]
         TASK_CONFIG_FILE = ${CYLC_WORKFLOW_RUN_DIR}/scripts/${CYLC_TASK_NAME}.config
         TASK_RUN_SCRIPT = ${CYLC_WORKFLOW_RUN_DIR}/scripts/${ CYLC_TASK_NAME}.scr

```

```bash
$ more job.status:
CYLC_JOB_INIT_TIME=2026-07-14T17:19:47Z
CYLC_JOB_EXIT=ERR
CYLC_JOB_EXIT_TIME=2026-07-14T17:24:35Z

```

So job died after 5 minutes, but wall clock given was 15 minutes.

---

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [July 15, 2026, 1:58am UTC](https://cylc.discourse.group/t/bash-xtracefd-error-in-batch-job/1330/2 "2026-07-15T01:58:57Z")

</div>

> [@bpabla50](#):
>
> what causes it? Is it can force to terminate job?

That’s to do with redirecting bash `set -x` output to `job.xtrace` in Cylc’s debug mode. There’s a 5 year old issue on the cylc-flow repository that suggests (a) it’s caused by a bug in bash version 4 (maybe 4.1 only); and (b) it does not actually cause Cylc jobs to fail. What is your bash version? (type `bash --version`)

> [@bpabla50](#):
>
> Only error I found in job.err is

If the executable you run in a Cylc task dies silently - i.e. it does not print anything useful to stdout or stderr before exiting - then there is nothing Cylc can do to help you with that; you need to fix the executable.

Perhaps your executable can be configured to run in its own verbose or debug mode (e.g. `script = "my-model.exe --debug"` or whatever), so you can see what it’s doing before it dies?

---

<div class="post-metadata">

**Author:** ![bpabla50](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@bpabla50](https://cylc.discourse.group/u/bpabla50)\
**Post date:** [July 15, 2026, 2:20pm UTC](https://cylc.discourse.group/t/bash-xtracefd-error-in-batch-job/1330/3 "2026-07-15T14:20:43Z")

</div>

Thanks @hilary.j.oliver

```auto
bash-5.1$ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)

I removed set -x from my script, hence I am no longer getting BASH_XTRACEFD error. Not sure, it makes sense or not, by removing set -x, it helped me in finding, my script was dying due to syntax error in my script.
Generally set -x helps in debugging your script code as it spits the output line by line to look at the values of your variables.
```

---

<div class="post-metadata">

**Author:** ![oliver.sanders](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/oliver.sanders/32/110_2.png) [@oliver.sanders](https://cylc.discourse.group/u/oliver.sanders)\
**Post date:** [July 15, 2026, 3:07pm UTC](https://cylc.discourse.group/t/bash-xtracefd-error-in-batch-job/1330/4 "2026-07-15T15:07:38Z")

</div>

FYI: Running a Cylc workflow with the `--debug` option (e.g, `cylc vip --debug <workflow>`) causes all job scripts to be invoked with “xtrace” for debugging. The output is written to `job.xtrace` and is separated from `job.out` and `job.err` (unless using an older version of Bash which does not support this separation).

See also the `cylc verbosity` command for toggling debug whilst a workflow is running.
