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 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. Note: The timeout period for the scheduler (three minutes), can be altered by modifying the config/config.ini file: Scheduler Sleep Timeout.
The serial 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.
# schedule.ini
# Schedule tasks for execution
[cron]
15,45 * * * * perl\perl.exe tmp\logtask.pl
10 4 * * * perl\perl.exe tmp\logtask.pl
[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.
# MIN HOUR DAY MONTH DAYOFWEEK = COMMAND
# at 2:20 a.m. every day .br 20 2 * * * = perl\perl.exe tmp\logtask.pl# every four hours at the top of the hour
0 */4 * * * = perl\perl.exe tmp\logtask.pl# every two hours from 11p.m. to 7a.m., and at 8a.m.
0 23-7/2,8 * * * = perl\perl.exe tmp\logtask.pl# at 11:00 a.m. on the 4th and on every mon, tue, wed
0 11 4 * mon-wed = perl\perl.exe tmp\logtask.pl# 1:00 a.m. on january 1st
0 1 1 jan * = perl\perl.exe tmp\logtask.pl
/session/ or /servlet/ RPC Execution
RPCs can be scheduled for execution as the following sample illustrates:
[daily]
Daily Template Regeneration = /session/url2file?fname=/docs/inline.htm&url=/samples/inline.stm
Daily Servlet Execution = /servlet/admin.Rebuild.class?name=/docs/foobar.htm
The above scheduled event uses the "special" /session/url2file RPC to execute the URL specified and direct it to disk. Run daily, the URL can take dynamically generated content and refresh a static page daily rather than each time the URL is requested. Note: Any output generated by the RPC command are written to session.out in the Sambar Server installation directory (this file is over-written by each scheduled RPC).
The /session/url2file template execution RPC can be especially useful when combined with either the /session/sendmail or /session/ftp RPCs. One company runs RDBMS reports using /session/url2file on templates, followed by /session/ftp to automatically copy the template output up to their internal report server.
[daily]
RDBMS Report = /session/url2file?fname=/docs/report1.htm&url=/dbms/report1.stm
Upload Report = /session/ftp?action=put&server=reportsrv&user=foo&pass=bar&rmtname=report.htm&locname=d:/sambar42/docs/report1.htm