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:
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:
Running a test does not change when the job is next scheduled to run.
Edit a scheduled job
Use these steps to modify an existing scheduled job:
Enable and disable a scheduled job
To enable or disable your scheduled job:
- In Jira administration, select Marketplace apps.
- Under Apps, select ScriptRunner.
- In ScriptRunner, select Scheduled jobs.
- Locate the scheduled job you want to enable or disable.
- 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:
- In Jira administration, select Marketplace apps.
- Under Apps, select ScriptRunner.
- Select Scheduled jobs.
- Find the scheduled job you want to remove.
- Open the ellipsis (…) menu for that scheduled job.
- Select Delete and confirm the deletion.
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:
- In Jira administration, select Marketplace apps.
- Under Apps, select ScriptRunner.
- Select Scheduled jobs.
- Use the filter and select Deleted to view deleted scheduled jobs.
- Find the scheduled job you want to restore.
- Open the ellipsis (…) menu for that scheduled job.
- Select Restore.