Scheduled scripts are agents that run at a specific time.
They're ideal for programming server machines, since they require no user action to get them going. You can easily set up a scheduled script to run every hour on the hour, or every fifteen minutes, or every night at 2AM. Or any of an almost infinite variety of different time combinations.
How it works
Choose Scheduler command from the Suites menu.
There are two menu items that add new tasks to the schedule. Add an Hourly Task adds a task that runs every hour-on-the-hour. It prompts you for a single-line script. If there's a task you want performed every night at 2AM, choose Add an Overnight Task.
Try it out. Choose Add an Hourly Task and click on OK to enter speaker.beep () as a new task. Do it again, and again, for a total of three hourly beeps. Now select the Open Tasks Table command. You should see three tasks, task1, task2 and task3. At the next hour (if it's 2:30PM, at 3PM), you should hear three beeps from the speaker, one right after the other.
If you want to see the list of tasks that have been scheduled, select the Open Tasks Table command. Here's what you see:
Here's what the first task table looks like:
For each task, we remember four pieces of information: the time interval in minutes between task runs, the next time the task is scheduled to run, an error string that's empty if the task ran without error, or contains the syntax or runtime error generated by the script and a one-line script that performs the task.
For real-world tasks, you're going to want to do more than beep the speaker. You can call any script from a scheduled task. Write the script in any object database cell, and schedule a call to the script. The script can be written in any OSA language.
The scheduler maintains a log of all the tasks it runs in an outline at suites.scheduler.log. Every time it runs one or more tasks it adds a headline to the log. You can open the log by choosing the Open Scheduler Log command from the Scheduler menu. You can turn this feature off by deleting the outline at suites.scheduler.log.
If you want to remove all scheduled tasks, you can delete the tasks table or choose the Empty Tasks Table command.
You can schedule tasks from your scripts using the scheduler.addTask verb. A page for this verb is in the DocServer database.
Check out suites.scheduler.examples.dummyTasks for for an example on how to add tasks from a script. It adds three tasks that display their name in Frontier's main window once a minute.
© Copyright 1996-97 UserLand Software. This page was last built on 5/7/97; 1:43:14 PM.
It was originally posted on 5/6/96; 9:12:04 PM.
Internet service provided by Conxion.