ServiceNow Scheduled Jobs Configurations

$1,000.00

Description

ServiceNow Scheduled Jobs

Let’s go through ServiceNow Scheduled Jobs configurations carefully and in detail. Scheduled Jobs in ServiceNow are automated tasks that run at defined times or intervals to perform system activities such as data imports, reports, or maintenance tasks.

1. Overview of Scheduled Jobs

In ServiceNow, scheduled jobs (sometimes called Scheduled Scripts or Scheduled Tasks) are configured to automate processes. They can:

  1. Execute server-side scripts.
  2. Run reports or exports.
  3. Perform maintenance tasks like cleanup or integration jobs.

The main table for scheduled jobs is:

sys_trigger – This stores scheduled job records, triggers, and their execution details.

2. Types of Scheduled Jobs

ServiceNow provides multiple ways to define a scheduled job:

  1. Basic Scheduled Job
  2. Runs a script at a specified time or interval.
  3. Can be created via: System Definition → Scheduled Jobs → New.
  4. Scheduled Script Execution
  5. Allows custom server-side JavaScript execution.
  6. Useful for automation that requires logic, like data updates or integrations.
  7. Report Scheduled Jobs
  8. Runs a report and optionally emails results.
  9. Useful for periodic reporting tasks.
  10. Event-Triggered Jobs
  11. Executes a job based on events rather than a time schedule.
  12. Less common but possible via Event Management.

3. Key Configuration Fields in Scheduled Jobs

When creating a scheduled job, you’ll encounter several configuration options:

Field Description
Name Friendly name for the job.
Run Defines the schedule: Once, Daily, Weekly, Monthly, or a Cron expression.
Time/Start When the job first runs.
Repeat Interval Time between executions for recurring jobs.
Active Whether the job is enabled.
Script Server-side JavaScript to execute (if using Scheduled Script).
Condition Optional script condition to determine if the job should run.
Email Optional notifications after execution.
Time Zone Executes based on the specified time zone.

4. Scheduling Options

  1. One-time: Runs only once at a specific date and time.
  2. Recurring: Can run on:
  3. Daily (e.g., every day at 2 AM)
  4. Weekly (e.g., every Monday at 6 AM)
  5. Monthly (e.g., 1st of every month at midnight)
  6. Cron expressions for advanced schedules.

5. Best Practices

  1. Use conditions to limit executions: Prevent unnecessary load on the system.
  2. Log results: Use gs.log() or create audit records for monitoring.
  3. Monitor executions: Use System Logs → Scheduled Jobs → Job Logs to track failures.
  4. Avoid overlapping jobs: Use gs.isScheduled() or check active records to prevent conflicts.
  5. Test scripts: Always test your scripts in a sub-production environment before scheduling in production.

6. Example

A simple Scheduled Script to close incidents older than 30 days:

var gr = new GlideRecord('incident');
gr.
addEncodedQuery('state!=7^opened_atRELATIVELE@dayofweek@-30'); // Not closed, older than 30 days
gr.
query();
while(gr.next()){
gr.
state = 7; // Closed
gr.
update();
}
gs.
log('Old incidents closed successfully.');
  1. This script could run daily at 2 AM.
  2. Logs results in system logs.
  3. Prevents unnecessary workload during peak hours.

If you want, I can also draw a diagram showing how Scheduled Jobs are configured and executed in ServiceNow—it’s very helpful for visualizing the process.

Do you want me to make that diagram?

Post your Comment About This Product