Contents ServiceNow Platform Previous Topic Next Topic Special cases in job schedules Subscribe Log in to subscribe to topics and get notified when content changes. ... SAVE AS PDF Selected Topic Topic & Subtopics All Topics in Contents Share Special cases in job schedules Some special cases require care in job scheduling. End of the month schedules Because months have different lengths, take care when scheduling jobs for the end of the month. Scheduling an event for the 29th or 30th is not recommended, because the scheduled job will not be executed in months (like February) which are shorter than those dates. If an event is scheduled for the 31st, it will be executed on the last day of the month, even if the month is shorter. For example, something scheduled to run on the 31st of the month will run on February 28th or February 29th in a leap year. Weekday schedules For scheduled scripts, use the following script to run only on weekdays: function checkWeekdays() { var now = new Date(); var day = now.getDay(); var result = false; if(day != 0 && day != 6) { result = true; } return result; } checkWeekdays(); Scheduled jobs from scripts To execute a scheduled job triggered by an event, use the following script: //Execute a scheduled script job var rec = new GlideRecord('sysauto_script'); rec.get('name', 'YOUR_JOB_NAME_HERE'); SncTriggerSynchronizer.executeNow(rec); This script can be run using one of several tables: scheduled_import_set (Scheduled Import Sets) sysauto_script (Scheduled Script Execution) sysauto_template (Scheduled Template Generation) sysauto_report (Scheduled Report) Note: SncTriggerSynchronizer does not provide methods to execute scheduled jobs in the future. Running Scheduled Jobs Imported from Another Instance To prevent unexpected data changes, the system does not automatically create Schedule Item [sys_trigger] records for Scheduled Jobs [sysauto] imported from an XML file such as an update set. To run a scheduled job imported from another instance, update the scheduled job record. Related TasksSchedule a reportSchedule a script executionSchedule the generation of an entityCreate a scheduled jobView a schedule itemCreate a scheduled jobSchedule the generation of an entitySchedule a reportSchedule a script executionView a schedule item On this page Send Feedback Previous Topic Next Topic
Special cases in job schedules Some special cases require care in job scheduling. End of the month schedules Because months have different lengths, take care when scheduling jobs for the end of the month. Scheduling an event for the 29th or 30th is not recommended, because the scheduled job will not be executed in months (like February) which are shorter than those dates. If an event is scheduled for the 31st, it will be executed on the last day of the month, even if the month is shorter. For example, something scheduled to run on the 31st of the month will run on February 28th or February 29th in a leap year. Weekday schedules For scheduled scripts, use the following script to run only on weekdays: function checkWeekdays() { var now = new Date(); var day = now.getDay(); var result = false; if(day != 0 && day != 6) { result = true; } return result; } checkWeekdays(); Scheduled jobs from scripts To execute a scheduled job triggered by an event, use the following script: //Execute a scheduled script job var rec = new GlideRecord('sysauto_script'); rec.get('name', 'YOUR_JOB_NAME_HERE'); SncTriggerSynchronizer.executeNow(rec); This script can be run using one of several tables: scheduled_import_set (Scheduled Import Sets) sysauto_script (Scheduled Script Execution) sysauto_template (Scheduled Template Generation) sysauto_report (Scheduled Report) Note: SncTriggerSynchronizer does not provide methods to execute scheduled jobs in the future. Running Scheduled Jobs Imported from Another Instance To prevent unexpected data changes, the system does not automatically create Schedule Item [sys_trigger] records for Scheduled Jobs [sysauto] imported from an XML file such as an update set. To run a scheduled job imported from another instance, update the scheduled job record. Related TasksSchedule a reportSchedule a script executionSchedule the generation of an entityCreate a scheduled jobView a schedule itemCreate a scheduled jobSchedule the generation of an entitySchedule a reportSchedule a script executionView a schedule item
Special cases in job schedules Some special cases require care in job scheduling. End of the month schedules Because months have different lengths, take care when scheduling jobs for the end of the month. Scheduling an event for the 29th or 30th is not recommended, because the scheduled job will not be executed in months (like February) which are shorter than those dates. If an event is scheduled for the 31st, it will be executed on the last day of the month, even if the month is shorter. For example, something scheduled to run on the 31st of the month will run on February 28th or February 29th in a leap year. Weekday schedules For scheduled scripts, use the following script to run only on weekdays: function checkWeekdays() { var now = new Date(); var day = now.getDay(); var result = false; if(day != 0 && day != 6) { result = true; } return result; } checkWeekdays(); Scheduled jobs from scripts To execute a scheduled job triggered by an event, use the following script: //Execute a scheduled script job var rec = new GlideRecord('sysauto_script'); rec.get('name', 'YOUR_JOB_NAME_HERE'); SncTriggerSynchronizer.executeNow(rec); This script can be run using one of several tables: scheduled_import_set (Scheduled Import Sets) sysauto_script (Scheduled Script Execution) sysauto_template (Scheduled Template Generation) sysauto_report (Scheduled Report) Note: SncTriggerSynchronizer does not provide methods to execute scheduled jobs in the future. Running Scheduled Jobs Imported from Another Instance To prevent unexpected data changes, the system does not automatically create Schedule Item [sys_trigger] records for Scheduled Jobs [sysauto] imported from an XML file such as an update set. To run a scheduled job imported from another instance, update the scheduled job record. Related TasksSchedule a reportSchedule a script executionSchedule the generation of an entityCreate a scheduled jobView a schedule itemCreate a scheduled jobSchedule the generation of an entitySchedule a reportSchedule a script executionView a schedule item