The Adaptavist Group LogoDocumentation

Scheduled Jobs

Learn how to create, schedule with cron expressions, test, and manage jobs that run scripts automatically at regular intervals.

You may want to use a scheduled job to:

  • Create a work item once per month.
  • Delete inactive users on a monthly basis.
  • Change the status of a work item depending on the time it has been open.

Output and logging

When you run a script, the output panel shows:

  • Anything logged with console.log(...).
  • The final value returned by your script with return.
  • The error, if the script failed, with the full untrimmed error behind Full error.

Use console.log(...) for messages, intermediate values, or debugging, and include a return statement for the main result you want to display.

Activity history

Saved scheduled jobs keep activity history, so you can review when they were run, and what the output was, making it easier to audit and troubleshoot. For how long activity is kept, see Run history retention.

Scheduling and timing

The minimum interval between job executions is 1 minute. Cron expressions with sub-minute intervals are not supported.

If you schedule multiple jobs with the same cron expression, they will show the same next run time, which is expected. When that time arrives, each job is queued to run, but they may not all start at exactly the same moment, and there is no fixed order in which they run. The actual start time can also vary slightly from one run to the next (for example, a job set to run every hour might start at 1:00 one time and 1:03 the next), depending on system load.

Create a scheduled job

Follow these steps to create a new scheduled job:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. Select Scheduled jobs.
  4. Select Create.
  5. Enter a Name and, optionally, a Description.
  6. Optionally, add Labels to group this job with others.

    Start typing to reuse an existing label. Labels are saved in lowercase, with hyphens instead of spaces.

  7. Enter a Cron expression (interval). This is how often you'd like your scheduled job to run.

    Select one of the example schedules below the field to fill it in for you, or write your own. For help building a custom expression, see this cron expression maker.

  8. Write your script.
    Tip: To help you write scripts, you can use the scheduled job examples, use HAPI, or select Example scripts directly in the script editor.
  9. Choose who you want the script to Run as. Select whether the scheduled job runs with ScriptRunner app permissions or as a specific user.
  10. Optional: Select Test scheduled job, then Run, to run your script and make sure it works as expected.
    • If the script performs updates (for example, creates or edits work items), those changes are applied to your Jira instance.
    • Test in a non-production environment first.
    • Use the Output panel to review results and troubleshoot any errors.
  11. Select Publish.

Test a scheduled job

You can test your scheduled jobs before relying on them in production. This lets you confirm that your script behaves as expected without waiting for its next scheduled time.

Unlike other script types, scheduled jobs need no test data. Nothing triggers a job except its schedule, so there is no work item, event, or transition to describe. Your script runs exactly as it would on schedule.

Test your scheduled job as follows:

  1. When creating or editing a scheduled job, select Test scheduled job.
    A testing panel displays.
  2. Select Run.

    The Output panel shows:

    • Anything logged with console.log(...)
    • The final value returned by your script with return
  3. If necessary, edit your script and test again until the output matches your expectations.
    Warning: If your script performs updates (for example, creates or edits work items, comments, or links), those changes are applied to your Jira instance even when running tests. Always test destructive or bulk-update logic in a non-production environment first.

Running a test does not change when the job is next scheduled to run.

Note: A test run is bound by the same time limit as a scheduled run. If your job processes a large number of work items, see Scripting limitations for how to split the work across several runs.

Edit a scheduled job

Use these steps to modify an existing scheduled job:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. Select Scheduled jobs.
  4. Find your scheduled job in the list and select Edit.
  5. Modify the scheduled job as needed.

    Your changes are saved automatically as a draft. The published version keeps running on its schedule until you publish again.

  6. Optional: Select Test scheduled job, then Run, to run your script and make sure it works as expected.
    • If the script performs updates (for example, creates or edits work items), those changes are applied to your Jira instance.
    • Test in a non-production environment first.
    • Use the Output panel to review results and troubleshoot any errors.
  7. Select Publish changes.

Enable and disable a scheduled job

To enable or disable your scheduled job:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. In ScriptRunner, select Scheduled jobs.
  4. Locate the scheduled job you want to enable or disable.
  5. Open the ellipsis (…) menu for that scheduled job and select Disable or Enable.

Delete a scheduled job

Remove scheduled jobs you no longer need to keep your list organized and reduce clutter. When you delete a scheduled job, it's removed from your active jobs list and will no longer run, but it isn't permanently removed. You can still access and restore it from ScriptRunner if needed.

To delete a scheduled job:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. Select Scheduled jobs.
  4. Find the scheduled job you want to remove.
  5. Open the ellipsis (…) menu for that scheduled job.
  6. Select Delete and confirm the deletion.
Note: Deleted scheduled jobs can be restored, including their activity history.

Restore a deleted scheduled job

You can restore deleted scheduled jobs along with their activity history so you can review past runs or start using them again.

To restore a deleted scheduled job:

  1. In Jira administration, select Marketplace apps.
  2. Under Apps, select ScriptRunner.
  3. Select Scheduled jobs.
  4. Use the filter and select Deleted to view deleted scheduled jobs.
  5. Find the scheduled job you want to restore.
  6. Open the ellipsis (…) menu for that scheduled job.
  7. Select Restore.

Search documentation

Start typing to search the docs.