# Job Notifications

{% hint style="info" %}
A license is required to use the functionality described on this page. Contact [DNAnexus Sales](mailto:sales@dnanexus.com) for more information.
{% endhint %}

Being notified of when a job may be stuck can help users to troubleshoot problems. On DNAnexus, users can set [timeouts](/developer/api/running-analyses/applets-and-entry-points.md#specifying-job-timeouts) to limit the amount of time their jobs can run, or set a threshold on how long a job can take to run before the user is notified. The notification threshold can be specified in the executable at compile time via [`dx`](/user/helpstrings-of-sdk-command-line-utilities.md) or [dxCompiler](/developer/building-and-executing-portable-containers-for-bioinformatics-software/dxcompiler.md).

When the threshold is reached for a [job tree](/user/running-apps-and-workflows/job-lifecycle.md#example-execution-tree), the system sends an email notification to both the user who launched the executable and the org admin.

## Setting Thresholds From the Command Line

For a root execution, the turnaround time is the time between its creation time and the time it reaches the [terminal state](/user/running-apps-and-workflows/job-lifecycle.md) (or the current time if it is not in a terminal state). The terminal states of an execution are done, terminated, and failed. The job tree turnaround time threshold can be set from the `dxapp.json` [app metadata](/developer/apps/app-metadata.md) file using the `treeTurnaroundTimeThreshold` supported field, where the threshold time is set in seconds. When a user runs an executable that has a threshold, the threshold applies only to the resulting root execution. See here for more details on the `treeTurnAroundTimeThreshold` [API](/developer/api/api-directory.md).

Example of including the `treeTurnaroundTimeThreshold` field in `dxapp.json`:

```json
{
  "treeTurnaroundTimeThreshold": {threshold},
  ...
}
```

In the command-line interface (CLI), the [`dx build`](/user/helpstrings-of-sdk-command-line-utilities.md#build) and `dx build --app` commands can accept the `treeTurnaroundTimeThreshold` field from `dxapp.json`, and the resulting app is built with the job tree turnaround time threshold from the JSON file.

To check the `treeTurnaroundTimeThreshold` value of an executable, users can use [`dx describe`](/user/helpstrings-of-sdk-command-line-utilities.md#describe) `{app, applet, workflow or global workflow id} --json command.`

Using the `dx describe {execution_id} --json` command displays the `selectedTreeTurnaroundTimeThreshold`, `selectedTreeTurnaroundTimeThresholdFrom`, and `treeTurnaroundTime` values of root executions.

## WDL Workflows

For WDL workflows and tasks, dxCompiler enables tree turnaround time specification using the [extras](https://github.com/dnanexus/dxCompiler/blob/develop/doc/ExpertOptions.md#extras) JSON file. dxCompiler reads the `treeTurnaroundTimeThreshold` field from the `perWorkflowDxAttributes` and `defaultWorkflowDxAttributes` sections in `extras` and applies this threshold to the generated workflow. To set a job tree turnaround time threshold for an applet using dxCompiler, add the `treeTurnaroundTimeThreshold` field to the `perTaskDxAttributes` and `defaultTaskDxAttributes` sections in the extras JSON file.

Example of including the `treeTurnAroundTimeThreshold` field in `perWorkflowDxAttributes`:

```json
{
  "perWorkflowDxAttributes": {
    {workflow_name}: {
      "treeTurnaroundTimeThreshold": {threshold},
      ...
    },
    ...
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.dnanexus.com/user/running-apps-and-workflows/job-notifications.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
