### Task-level timeout for advanced run and schedule tasks

A task-level timeout mechanism is introduced in order to avoid the never-finished running tasks consuming server resources and thus decreasing the server performance. With the mechanism, you can specify a time duration for a task, and ask JReport Server to cancel the task or to notify you or someone else of the task status via e-mail if the task has not yet finished running when the task duration is up. To do this:

1. Do either of the following to enable the task-level timeout mechanism.
   - In the server.properties file, set the task.duration.enable property to true.
   - On the JReport Administration page, click Configuration on the system toolbar, select Advanced, and then check the Enable Task Duration option.
2. Set task duration check frequency. By default, JReport Server checks task duration every 30 seconds. The period value can be reset either by the task.duration.check_cycle property in the server.properties file or by the Status Refresh Interval option in the Configuration > Advanced panel on the JReport Administration page. Note that the value must be an integer greater than 0. Since task duration check frequency affects server performance, it is recommended that you set the value according to your system environment.
3. Restart JReport Server if you have modified the Advanced panel.
4. Use the Duration tab in the Advanced Run and Schedule dialogs to specify task duration.
   1. In the Timeout text box, specify the time limit for when the task can run before notifying of the timeout or canceling the task.
   2. If you want to notify someone of the task status if the task has not yet finished running when the task duration is up, check Notify by e-mail after the specified time and specify the mail address in the Mail To text box.
   3. If you want JReport Server to cancel the task when the task duration is up but the task is not finished yet, check Cancel the task after the specified time.
   4. Click Finish to submit the task.

Then, when the specified task duration is up but the task has not finished running,

- For an Advanced Run task,
  - If you have specified to have server cancel the task when the task duration is up, the task will be cancelled automatically, however a record for the task will be still remained in the Background Tasks table of the My Tasks page, shown with a sign of cancellation.
  - In the Duration tab, if you haven't checked the option Cancel the task after the specified time, the task will be switched to run in background mode when the task duration is up, in which case, you can choose to cancel the task manually. To do this, in the Background Tasks table,
    - Select the task row and click Edit > Delete on the task bar of the My Tasks page.
    - Select the task row, right-click in the row and select Delete from the shortcut menu.
    - Put the mouse pointer over the task row and click the Delete button on the floating toolbar.
- For a Schedule task,
  - If you have specified to have server cancel the task when the task duration is up, the task will be cancelled automatically, and a task completed record will be added in the Completed table of the My Tasks page, with the Is Successful status shown as No.
  - In the Duration tab, if you haven't checked the option Cancel the task after the specified time, the task will still be listed in the Running table of the My Tasks page when the task duration is up. Then, if you want to cancel the task manually, in the Running table,
    - Select the task row and click Stop on the task bar of the My Tasks page.
    - Select the task row, right-click in the task row and select Stop from the shortcut menu.
    - Put the mouse pointer over the task row and click the Stop button on the floating toolbar.

Notes:

- JReport Server may not cancel a task right after the specified task duration is up due to check frequency.
- It is recommended that the task duration is set to about five times of the required time for finishing running the task.