Run scheduled job based on time zone

chadlockwood
Kilo Sage

We have a job that runs daily to add new hires to an Active Directory group on their start date. This job runs every morning at 12:30am PST. The problem is that starters around the globe are waiting well into their first day before they are granted the permissions that the AD group gives them. For example, a new hire is Singapore is not added until 2pm Singapore time.

I need to create a scheduled job that will run at 6am (anytime between 12 midnight and 8am local) in each timezone around the globe and only run against starters in that timezone.

I have attempted to create three separate jobs that run at 11am (to cover all of APACJ from approx 12 midnight to 8am), 3pm (for EMEA), and 3am (for North/South/Central America and Hawaii). These are all working ok, but I'm wondering if there is a better, smarter way. This solution does not take time changes into consideration so there is a chance that someone could get added prior to midnight which would be a security violation.

8 REPLIES 8

I also agree with Jeff, we can run the Job probably at 30mins to 1 hr interval and we are good to go

Every 30 minutes would be fine but how would I tell the script that it is now 6am in X time zone so update the starters in that time zone?

In the script, you can use setTimeZone function within the loop of the users you are processing.  Then when you get the current time, it will be based on that timezone.  The hard part is determining the time zone for the user if they are new.

Jeff Currier
ServiceNow Employee
ServiceNow Employee

I think your need to schedule multiple jobs like you have.  To only get those users for a particular time zone, you will need to filter either when you grab them or upon import.  Is there a field available to you in AD you can use?  Different OUs?  Some other AD Attribute based on location or TZ?  If so, you would want to filter based on that attribute.