Assuming that you always want to start missing jobs if the server was not available for whatever reason, I suggest that you create a special "heart beat" job. Such job should run every minute or so and write current date/time into some .INI file or registry. It will also read the last written date/time value and compare with the current date/time. If the difference is greater than 2 minutes, it will check scheduled start time for the specified jobs and if it is between the last and current heart-beat time, start them. Here is a sample script for such processing. You may need to make some changes in it to handle various exceptions, for example, you may want not to start some jobs even if they are missed. This script will only process "daily and weekly" jobs. This simple version also assumes the downtime falls on a single day. ================================================================= Dim datetime_now, datetime, "@T"mm/dd/yyyy hh:mm"" Dim datetime_last, datetime Dim seconds, number Dim downtime_processing, boolean // get last time IniFileGetKey "c:\\heartbeat.ini", "Time", "Last Run", datetime_last // save current time IniFileSetKey "c:\\heartbeat.ini", "Time", "Last Run", datetime_now // compare the difference DateTimeDiff datetime_last, datetime_now, seconds IsGreater seconds, 120, downtime_processing // if downttime detected, proceed to start label, otherwise exit IfThen downtime_processing, START Exit START: Dim job_list, string Dim done, boolean Dim job_id, number Dim schedule_type, string Dim is_daily_job, boolean Dim start_time, time Dim is_missed_day, boolean Dim is_missed_time, boolean Dim is_missed_job, boolean Dim day_name, string Dim run_today, string Dim command_line, string Dim process_id, number // get todays day name DayName datetime_now, day_name // get job list JobList "", job_list // process job by job LoopUntil done, END_LOOP GetToken ",", job_list, job_id // get schedule type (e.g. daily, montly, file watch, etc...) JobDescribe job_id, "SCHEDULE_TYPE", schedule_type // process daily jobs only isEqual schedule_type, "D", is_daily_job IfThen is_daily_job, CHECK_TIME // check if there are more jobs in the list isEqual job_list, "", done Continue CHECK_TIME: // get and compare job start date and time time JobDescribe job_id, "START_TIME", start_time JobDescribe job_id, day_name, run_today // if job is setup to run today and was missed start it isEqual run_today, "Y", is_missed_day isTimeBetween start_time, datetime_last, datetime_now, is_missed_time And is_missed_day, is_missed_time, is_missed_job // ok that job is missed, start it // JobRun job_id -- this non asynchronious and prevents overlaping jobs Concat "24x7 /JOB ", job_id, command_line Run command_line, "", process_id // check if there are more jobs in the list isEqual job_list, "", done END_LOOP: ================================================================= Because of the JobList statement this script requires 24x7 version 3.1.3 or better. Feel free to ask, if you have any questions about this script. : Our concern is with overnight batch processing in an environment where most : on-line access is during business hours. There are about 5 : non-interlapable Win32 jobs which must run each night, of very roughly an : hour long each. There is also lots of weekend batch processing. Such must : be scheduled with respect to progress of mainframe jobs, so as to keep our : SQL Server database safely backed-up and in sync with the mainframe : database. : The most common cause of Win32 downtime is computer site staff (I'm from a : programming group) doing hardware and OS upgrades. They do tell us in : advance that they will be doing such, but estimates of how long it will : take are inaccurate. The aim is to automate our processing as much as : possible, avoiding risky ad-hoc changes to the schedule. We're buying a : better scheduler (we now use the SQL Server Agent) to address this : concern, and because we need finer grained security offered by 24x7.
|