WinCron 1.91
Related Links: | ||
CronIco | WinCron management tool | |
CronLog | manages your WinCron log files |
INTRODUCTION:
WinCron is basically a Windows implementation of the UNIX cron program.
WinCron runs under Windows 95, 98 & Windows NT. The main advantage this
program has over many of the event scheduling programs already out there
(besides being free) is that it can read the event table as a text file from any
drive. This allows you to alter the events that are being scheduled without
having to have access to the console of the computer that WinCron is running on.
Editing the text file can be done from any machine that has sufficient rights to
alter the file.
INSTRUCTIONS FOR USE:
WinCron was written in Visual Basic 6.0 and requires standard VB libraries (MSVBVM60.DLL & OLEAUT32.DLL).
The event (crontab) file is limited to 1000 lines. If you should need
more then that, a second instance of WinCron can be launched and a different
event file can be specified for the second instance. WinCron uses the same
convention as many UNIX crontab files, a plain text file with each line having
six fields separated by one or more spaces. The logical operator between all
fields is "AND"; therefore, every field must be true before the instruction will
be executed.
The fields are as follows:
1. Minute (0-59)
2. Hour (0-23)
3. Day of Month (1-31)
4. Month (1-12)
5. Day of week (0-6) (0 being Sunday)
6. The instruction you wish to execute.
Example entry:
01 02 03
* * c:\batch\cleanup.bat
This line would start the "cleanup.bat" batch file at 00:01 (02:01am) on
the third day of every month, regardless of the day of the week.
It is also acceptable to schedule multiple times for a program to run by
separating entries with a comma. If this is done, you should use two digits for
each entry in the "Minute", "Hour", and "Day of Month fields". In the "Day of
Week" field, each entry must be a single digit. There cannot be any spaces
between the comma-separated entries.
Example:
01,02,03 01
01 *
1,2,3,4,5 c:\batch\cleanup.bat
Additional logical functionality is available through the use of a "NOT"
operator. Acceptable symbols for a logical "NOT" are "-" or "!". This allows an
event to be started at times that Do Not match the entry in the event file. It
is important to keep in my that the logical AND is still used between fields. So
in the below example the cleanup.bat file wouldn't run on any day that was
either the 13th or a Friday.
Example:
01 06 *
!13 * !5
c:\batch\cleanup.bat
To create an entry that runs everyday except Friday the 13th you would have to set it up as follows:
01 06 *
!13 * *
c:\batch\cleanup.bat
01 06
* 13 *
!5 c:\batch\cleanup.bat
Multiple values with the "NOT" operator may be included in the same field
if separated by commas. There cannot be any spaces between the comma-separated
values. However, if there is one logical "NOT" operator in the field, all values
within the field will be considered to be preceded by the "NOT" operator. This
means that !1,!2 is the same as !1,2.
Example:
01 * !07,!13
* !5 c:\batch\cleanup.bat
WinCron can be used to schedule events that are to be run only once. To
use this functionality place an @ symbol at the beginning of the first (the
minute) field. For obvious reasons, wildcards cannot be used when running a
program only once. The last field (the day of week field) is used as a year
field when scheduling an event to run only once. All fields must be filled in or
the line will be ignored.
Example:
@01 01 01 01 1998 c:\batch\cleanup.bat
Starting a line with "@launch" will cause that line to be passed to the
operating system's command interpreter as soon as WinCron launches. This is
particularly useful for starting CronIco at the same time WinCron is
launched.
Example:
@launch c:\batch\startup.bat
Starting a line with "#" will cause that line to be ignored, so remarks
may be placed in the event (crontab) file. The "#" should appear as the first
character of the line and must be followed by at least one space. Remark lines
count against the 1000 line maximum of the event file.
Example:
# This is a comment line
Because Windows 95 and Windows NT have slightly different ways of
initiating an asynchronous process, it is recommend that you place the commands
to be run in a batch file and use WinCron to start the batch file. This will
allow you to set any parameters or handle any decision making logic outside of
the WinCron program.
Using batch files also allows you to use MS-DOS shell switches to control
how the program being launched is handled. Windows .pif (shortcut) files can
also be used to control how the batch file is run. Because this software is
often run on servers, I have attempted to leave most program control
functionality to the shell in the interest of stability.
To start WinCron, simply launch it from the command line or from a short
cut. The path and file name of the crontab file MUST be specified at the command
line (i.e. WinCron f:\util\crontab.txt). The only purpose of the large button in
the middle of the main form is to check if the program is still responding.
Pressing this button updates the button's caption to indicate current status and
time.
Double Clicking on the text box that shows the crontab file being used
launches Microsoft Notepad (if it is in the system path) to edit the file.
The program reloads the event table every 60 seconds. The switch
/NoUpdate can be used to prevent WinCron from updating the crontab file. If this
switch is used, WinCron will only load the crontab file once when first
launched.
Example:
WinCron f:\system\util\crontab.txt /NoUpdate
There is also a /Hide switch that has been added at the request of
several sysadmins. This will prevent the user from being able to see that
WinCron is running; however, this means the only way for the sysadmin to check
on the program is to hit crtl-alt-del and look at the task list.
Example:
WinCron f:\system\util\crontab.txt /NoUpdate /Hide
Logging can be enabled by using the /Log switch at the command line.
WinCron only logs errors and program launches. If the exit status of a program
is needed, then the batch file used to the launch the program must be used to
record this information. The log file is always named the same as the crontab
file with an extension of .log appended to the end. That means that if you name
your crontab file "crontab.txt", the log file will be named "crontab.txt.log".
This has been known to cause problems on systems where the crontab file is being
stored on a network drive that does not support long file names. If you run into
this problem, my suggestion is to simply call the crontab file "crontab" with no
extension, so that appending .log will result in a log file named "crontab.log".
Double Clicking on the text box that shows the log file size will launch
Microsoft Notepad (if it is in the system path) to view the file. If the log
size exceeds 5 Megabytes the text box showing log file size will change to color
to red.
Example:
WinCron f:\system\util\crontab.txt /NoUpdate /Hide /Log
There has been some debate as to how to handle errors in a cron type
program. The default action is for WinCron is to simply fail and exit on any
error. The reason for this is that often cron programs are used to schedule
several events in a specific sequence. A lost network connection or similar
event could cause unpredictable results. The safest way to handle errors seems
to be halting all events until the situation can be evaluated. If you would
prefer WinCron to continue to process events after errors, the /ContinueOnError
switch may be used. Note: Depending on your system the program may still fail
and exit if logging is switched on and the log file becomes inaccessible.
Also remember, multiple instances of WinCron can be launched on the same
computer. Each instance can be launched with different switches, so a table
containing events that must be run in sequence and one containing unsequenced
events can both dealt with in different modes on the same machine.
Example:
WinCron f:\system\util\crontab.txt /NoUpdate /Hide /Log
/ContinueOnError
I would like to extend special thanks to cydo@rype.de who developed CronIco.
I hope that this program is useful to you. I can make no claim as to this
software's stability or value. It is being offered as is. Use at your own risk.
If you find it useful, all I ask is that you please email me at graysteel@erols.com just so I know that
it's useful to someone. The Author reserves all copyrights. Permission is
granted to any individual or institution to use, copy, or redistribute this
executable so long as it is not modified and that it is not sold for profit.
Also, feel free to email any suggestions for revisions to the program.
REVISION HISTORY
--1.91--
Compiled with VB 6.0 rather then VB 4.0
@launch functionality added
"Heartbeat" function for CronIco added
Blank lines now allowed in crontab file for neater formatting
Logging detail now includes task ID or launch failure
--V1.84--
Carriage return no longer needed after the last line in crontab file
--V1.83--
Yet again more tolerant field parsing
Added small command line help screen with /? or /help
--V1.82--
Font display error on some systems fixed
Wording change in error reporting
--V1.81--
Graphical interface switch setting added
WinCron launch now logged (for security reasons)
Slightly reduced CPU load on event testing
--V1.71--
Logical NOT operator added
Log file size indicator added
Improved file sharing of log files
Reduced CPU load on disk read
More tolerant field parsing
Limited crontab error testing
--V1.61---
@ Functionality added
/NoUpdate bug fixed
Reduced CPU load and delay on start up
Improved sharing of crontab file