OS/2 eZine - http://www.os2ezine.com
Spacer
June 16, 2002
 
Robert Basler is the president of Aurora Systems, Inc. and has been a dedicated OS/2 user since he tired of rebooting Windows 3.1 twenty times a day. He spends what free time he can manage travelling the world. Photo was taken at Franz Josef glacier, New Zealand.

If you have a comment about the content of this article, please feel free to vent in the OS/2 eZine discussion forums.

There is also a Printer Friendly version of this page.



Spacer
Previous Article
Home
Next Article


Do you have an OS/2 product or service you'd like to advertise?


Scheduling Solutions

After a brush with death with my company's support database this month, I decided it was time to have the database automatically backed up each night. After digging through the MySQL documentation, I was able to find the command I needed to run, but I was left to my own devices to find a method to have this command executed each night.


RSched 1.6

A visit to hobbes netted me RSCHED16A4.ZIP. This is a VIO scheduler and it sounded like it would fit the bill. I got it set up, and discovered it works exactly as advertised except for one thing: it accesses the disk to check for changes to its list of scheduled tasks every second. That means that the drive can never go to sleep, clearly unacceptable on a system that runs 24x7. I was able to increase the delay to access the disk, but the documentation warns that if you do this that it might miss events (Ack!) In any case, the delay can be increased only up to 999 seconds (16 minutes) so the drive wasn't going to be able to go to sleep with this program running. In the end, while I liked the simple user interface and the extensive job control options, I had to look for something else.

PM Cron Daemon

My next try at hobbes, I decided to try something with UNIX history, since I've long known of UNIX's propensity for automating tasks. This netted me pmcron03.zip.

When PM Cron Daemon runs, it displays as a small PM window with information on when the next CRON job will be executed. The nice thing here is that it figures out when the job is going to run, and then sleeps until then.

When you want to set up jobs to be run automatically, or to change settings, the settings are integrated with the daemon program, so you don't have to restart like you do with many other servers. Actually setting the program to run jobs at a given time is where the program shows its UNIX roots. You have to enter a command line of sorts in a given format to get Cron to run the job when you want it to. This isn't difficult, but a couple of text boxes with labels would have made it much easier.

Cron Command Format

The format of a Cron command is

[flags] times command

  • Where [flags] can be Once to indicate that the job is to be done only once, and then deleted from the crontab file (where these commands are stored by the Cron Daemon.)
  • Times consists of 5 entries, each of them must pass the time check to run the command. They are:

    Minutes - the minute within an hour that the job should start (0-59).
    Hours - the hour of the day that the job should start (0-23).
    Month day - the day of the month the job should run (0-31). Note, while Feb 31 is a valid entry, don't expect it to actually ever run.
    Month - the month the job should run (1-12).
    Day of the week - the day of the week the job should run (0-6 - where 0 is Sunday).

    There are three special times that can replace the 5 time entries: cronstart - run job when cron daemon is started, cronstop - run job when cron daemon is stopped, daily - run the job once a day at the first possible time.

    If you don't want to specify one of the five fields, put * instead of the number.

  • The command can be any possible OS/2 command. You can append >nul 2>&1 to the command line to have output from the command suppressed. You can also have the output routed to a file, and the cron daemon has facilities for managing those files.

Examples

To have e:\backup.cmd run every day at 3:15am, use the following command:

15 3 * * * cmd.exe /ce:\backup.cmd >nul 2>&1

To have c:\yourapp.exe run on the first and 15th of each month, use the following commands:

* * 1 * * c:\yourapp.exe >nul 2>&1
* * 15 * * c:\yourapp.exe >nul 2>&1

To have c:\thisapp.exe run every Friday at 6:00pm, use the following command:

0 18 * * 5 c:\thisapp.exe >nul 2>&1

Summary

As you can see, PM Cron Daemon is quite easy to use, and has proven most reliable in my use. The program is available in both English and German, comes with extensive online help, and is GPL licensed. If you're looking for a scheduling solution, this is one to try. If you speak other languages, the author is looking for people to do translations. See the included readme file for details.

Previous Article
Home
Next Article

Copyright (C) 2002. All Rights Reserved.