Task Scheduler

The Sambar Server has a built-in task scheduler for managing events such as log file rotation, search re-indexing, and dial-on-demand. User-defined events can be configured in the config/schedule.ini file.

The Sambar Server Scheduler is not particularly sophisticated. Events can be scheduled for: hourly, daily, weekly or monthly execution. The scheduler thread runs every two minutes to service scheduled tasks, and all tasks are executed serially in the order they were scheduled. So if several events are scheduled to execute 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.

The simple nature of the scheduler can affect the server adversly if time-sensitive features such as dial-on-demand are being used in addition to longer-running tasks. For example, dial-on-demand feature uses the scheduler to determine if the connection should be "hung-up". If the task to test the "hang-up" condition cannot run because of a long-running task (such as log-file rotation/processing), the "hang-up" will not occur until the previous event completes.

Task Termination

All tasks should terminate and return an error code of 0. By default, any user-defined tasks that are still running after 5 minutes are terminated. The duration of the Scheduler timeout can be configured via the config/config.ini file: Scheduler Task Timeout.

schedule.ini file

The format of the config/schedule.ini file is as follows:

# schedule.ini
# Schedule tasks for execution

[hourly]
Hourly Perl Test = perl\perl.exe tmp\logtask.pl

[daily]
Daily Perl Test = perl\perl.exe tmp\logtask.pl

[weekly]
Weekly Perl Test = perl\perl.exe tmp\logtask.pl

[monthly]
Monthly Perl Test = perl\perl.exe tmp\logtask.pl

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.