Sambar Server Documentation
|
Task Scheduler |
The Sambar Server Scheduler has two scheduler modes, a UNIX cron implementation, and a simple scheduler for: hourly, daily, weekly or monthly execution. The scheduler thread runs every minute to service scheduled tasks, and executes tasks either serially in the order they were scheduled or in parallel. If the task is executed serially (the default), and several events are scheduled to execute at the same time (i.e. weekly), the first will begin executing Sunday at midnight and the others will execute after each preceeding task completes. So if the first task takes 5 minutes, the second task will not run until Sunday at 12:05AM. Note: The timeout period for the CRON scheduler is every minute.
The serial nature of the scheduler can affect the server adversly if time-sensitive features are being used in addition to longer-running tasks. Any task that will take more than a second should be executed in parallel.
[cron]
[hourly]
[daily]
[weekly]
[monthly]
[startup]
[shutdown]
# schedule.ini
# Schedule tasks for execution
15,45 * * * * perl\perl.exe tmp\logtask.pl
10 4 * * * perl\perl.exe tmp\logtask.pl &
Hourly Perl Test = perl\perl.exe tmp\logtask.pl
Daily Perl Test = perl\perl.exe tmp\logtask.pl
Weekly Perl Test = perl\perl.exe tmp\logtask.pl
Monthly Perl Test = perl\perl.exe tmp\logtask.pl
Startup Perl Test = perl\perl.exe tmp\logtask.pl
Shutdown Perl Test = perl\perl.exe tmp\logtask.pl
Blank lines and leading spaces are ignored. Lines whose first non-space character is a pound-sign (#) are comments and are ignored. Lines ending with an ampersand (&) are executed in parallel.
The section heading (i.e. [hourly]) indicates when the scheduled task should run. Tasks running daily run at 12:00AM, weekly tasks run at 12AM on Sunday, monthly tasks run on the 1st of the month at 12AM. Section can then have multiple entries for actions to take; in the above example, a simple task is started which logs the occurence of the event to the file tmp/logtask.log.
The name = command pair identifies the symbolic name of the task (for logging and debugging purposes), and the command to be executed. The command is passed to the CreateProcess() windows command; your should test all task commands in a DOS command shell to ensure they will work properly when executed by the Scheduler.