What This Table Is
The sysauto_script table stores scheduled script executions — automated tasks that run on cron schedules to perform system maintenance, data cleanup, and recurring business logic. Each record defines a script to execute, when to run it, and tracks execution history including last run time and next scheduled execution.
Owned by the Platform module, this table supports ServiceNow's built-in scheduled job framework. The scheduler service reads these records and executes the JavaScript code at the specified intervals. Common uses include data archiving, cache clearing, integration synchronization, and automated report generation.
The table extends sys_metadata but doesn't have child tables extending it. Records are scoped to the application that creates them, though global scheduled scripts can access any scope. The table integrates tightly with the sys_trigger table for execution scheduling and the syslog table for execution logging.
Most instances have 20-50 scheduled script records, though large enterprises may run 100+ automated jobs. Performance is rarely an issue since the scheduler processes records sequentially, but poorly written script content can impact system performance when executed.
When You'll Script Against This Table
You'll typically script against sysauto_script in Script Includes that manage scheduled jobs programmatically, Business Rules that trigger when job configurations change, and REST APIs that expose scheduling functionality. Administrative scripts often query this table to audit scheduled jobs or temporarily disable problematic scripts.
Access requires the admin role by default, as scheduled scripts can execute privileged operations. The script field containing the JavaScript code is particularly restricted and may not be readable in scoped applications without elevated privileges.
- Create scheduled jobs programmatically through REST or script
- Monitor job execution status and last run times
- Temporarily disable jobs during maintenance windows
- Audit scheduled job configurations across applications
- Update job schedules based on business rule triggers
- Clone or template scheduled jobs for new environments
- Generate reports on automated job frequency and performance
Table Gotchas
The script field stores JavaScript as a string but executes in global scope regardless of the record's application scope. Scoped app scripts can access global APIs they normally couldn't reach.
- The
activefield doesn't immediately stop running jobs — the scheduler checks this flag before the next execution, not during current execution
Updating the run_time field doesn't reschedule the job. You must also update the sys_trigger record or use the ScheduledJobManager API to change execution timing.
- The
last_runtimestamp updates even if the script throws an exception — checksyslogfor actual execution results - Queries against
scriptfield content are expensive — the field isn't indexed and contains large text blocks
Deleting sysauto_script records leaves orphaned sys_trigger records. The jobs won't execute but the triggers remain in the queue until manually cleaned up.
- The
run_asfield only affects script execution context when populated — empty values run as system, not the job creator
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.
Related Tables
The sys_trigger table maintains the actual execution schedule for each scheduled script, storing next run time and trigger state. The syslog table captures execution results, errors, and performance metrics for each job run. Both tables reference sysauto_script records to provide complete job lifecycle management.
When scheduled scripts modify data, developers commonly join sysauto_script with target tables like task or custom application tables to audit automated changes. The sys_user table links through the run_as field to track execution context and permissions.