Scheduled Jobs

What are Scheduled Jobs?

Scheduled Jobs allow you to automate the running of scripts at regular intervals saving your administrators time, and reducing the risk of human error. You can specify when, and how often, a job should run.

How to use Scheduled Jobs

You may want to use a Scheduled Job to:

  • Create an issue once per month.

  • Email a report to users, on a schedule.

  • Delete inactive users on a monthly basis.

  • Change the status of an issue depending on the time it has been open.

  • Automatically escalate an issue based on the elapsed time using Escalation Services.

Say, I have a team of consultants who need to fill out expenses at the end of every month. I can create a Scheduled Job to automatically create a task for each user at the end of every month to remind them to complete their expenses.

As a Jira administrator, it's key to keep my instance healthy and reduce costs by removing inactive users. I can set up a job to run a script that deletes inactive users on a monthly basis.   

Before you start

Understand how Scheduled Jobs work by viewing our training modules.

Broaden your horizons by exploring the Adaptavist Library for Scheduled Jobs script examples.

Create a Scheduled Job

You can use Scheduled Jobs to ensure code runs either at a specified time of day/week/month, or on an interval, in order to perform an automated task in your Jira instance. 

The minimum interval between code executions is 1 hour. The scheduler is triggered every hour and gathers all the tasks to be executed within that hour. The task executions are queued and workers will consume them in no predefined order. That means that the execution time of the task can not be guaranteed to be the same every hour. As an example: if you configure a job to be run every hour, it might be run at 01:02 and then 02:24 and then 03:00 and then at 04:46 etc depending on how busy our systems are.

Follow the steps below to use this feature:

  1. Navigate to ScriptRunner → Scheduled Jobs. Open opening the Scheduled Jobs page, you are presented with either a list of previously created jobs, or you will see a landing screen if you have not previously created any scheduled jobs.
    1. From the list of previously created jobs page, you can select your preferred job and either Edit or Delete it via the Actions ellipsis.

    2. From the initial landing screen, in the case where no jobs have been previously created, you can choose between the option to add example jobs to your instance by clicking the Add Examples button, or to create a new job by clicking the Create Scheduled Job button.

      In the case of adding examples to your instance, you will see a list of two example jobs displayed on the Scheduled Jobs page. As is the case in the previous step, from here, you can select your preferred example and either Edit or Delete it via the Actions ellipsis.
  2. If you have chosen to create a new scheduled job, you will see the following screen displayed:
  3. Name the job and click either the Enabled or Disabled option, as required. When set to Enabled, the scheduled job is active as soon as it has been saved.
  4. Click on the edit pencil within the On this schedule field.
    • The Scheduler dialog lets you choose between running your script on several days during the week (e.g. Monday, Wednesday, Friday), or running your script on particular days of the month (e.g. the last day of the month, the 2nd Tuesday of the month).
    • Additionally, you can select an hour interval during which time your script will run.
    • Each Scheduled Job can execute for the same length of time as Script Listeners, Post Functions and in the Script Console as documented in the script limitationsSee also the Escalation Service that lets you configure code that will be executed against each issue returned from a JQL search, on a schedule. This is useful for performing automated transitions/releases/updates of issues.
    • There is a possibility to test your script using Run Now button that will execute the script and return the results and the logs.
  5. If you have chosen to edit an existing scheduled job (as outlined in Step 1), you will see the following screen displayed:
  6. Amend the fields as required. As previously noted, you can click the Run Now button to test your script.
  7. Click Save.
On this page