home *** CD-ROM | disk | FTP | other *** search
- Cron 1.1
- (c) 1991 -- Kyle A. York
- ------------------------
-
- Here's my attempt to port the Unix Cron utility to MS-DOS. Feel free
- to do with program as you please --but-- always leave my name in the
- source and documentation and ALWAYS note any changes you have made. I
- don't want bad code running around with my name on it.
-
- Acknowledgements
-
- Ralph Brown for his invaluable interrupt list and DVGLUE library.
-
- Command Format
-
- CRON [-c filename] [-d filename] [-l filename] [-l-] [-m memsize]
-
- -d filename : set the template .dvp file to filename
- -c filename : set the CRONTAB file to filename (default is crontab
- in the same directory as cron.exe)
- -l filename : set logfile to filename (default is cron.log in the
- same directory as cron.exe)
- -l- : disable the log file
- -m memsize : set the CRONTAB buffer to memsize. default is 1K.
-
- This is meant to be run in it's own window. The "cr-pif.dvp" file
- provided should work for most people (after changing the program path &
- such).
-
- CRONTAB format
-
- the first 5 fields are: minute (0-59), hour (0-23), day of month (1-
- 31), month of year (1-12) and day of week (0-6, 0=sunday). A '*' is
- used for "any allowable value". The fields are seperated by spaces.
-
- ex: 0 0 1,15 * 3 [switches] {command} [paramaters]
-
- will execute the command at 00:00 on the 1st and 15th of every month
- and on every Wednesday. The number list can be comma-seperated
- (1,15) or ranges (1-5,6-9). VERY LITTLE error checking is done. If a
- number is out of range, it will never be found so {command} will
- never be executed. If a * appears anywhere in the field, the fields
- will ALWAYS match (eg 1,2,4-7,*,9 is equivalent to *). A range is
- assumed to be low to high. If it is entered high to low, only the
- limits will match (eg 7-4 will match 7 and 4, but not 5 and 6
- whereas 4-7 will match 4,5,6,7).
-
- {command} format
-
- This is where I had to deviate somewhat from the UNIX format. The
- command can be optionally preceded by some switches as follows:
-
- -b : force this window to start in the background
- -c n : if n < 0, set minimum conventional memory to -n K
- : if n > 0, set maximum conventional memory to n K
- : this might seem kind of clunky but its the best I could
- : think to do.
- -e n : set maximum expanded memory to n K
- -h : force this window to start hidden
-
- If the command has the extension '.exe', '.com', or '.dvp' it must
- also have the full path to reach the file. In other words the DOS
- path is not traversed to find the program. Any other extension
- (most notably ".bat") will load the current command shell
- (normally COMMAND.COM) and pass the command as a parameter.
-
- If the command has an extension '.exe' or '.com' the window is set
- to close on completion. If it has a '.dvp' then the command is run
- verbatim from the info in the '.dvp'. If it has any other
- extension, the command interpreter is loaded and the command is
- sent to the interpreter. Generally if you are running a batch file
- and you want the window to close on completion, the last command
- in the batch file should be 'exit'.
-
- parameters format
-
- The parameters string is parsed for the following strings:
- %M, %D, %h, %m
- If these are found, %M is replaces with the 2-digit month, %D with
- the 2-digit day of month, %h with the 2-digit hour, and %m with
- the 2-digit minute. An example of this is included in the example
- CRONTAB file. I needed a way to backup my disks using a unique
- name, and the month + day strings worked quite well.
-
- After this parsing, the parameters are sent to the program.
-
- Limitations
-
- DesqView allows only 63 characters for the full path to the program,
- and 63 characters for the parameters. If the parameters string is
- greater than 63 characters it is truncated with a warning written to
- the log file. If a '.bat' file is run, the path to the program is
- cleared and the parameters are set to the program name + parameters
- therefore the full string (program name + parameters) must be less
- than 63 characters. If not it is truncated with a warning written to
- the log file.
-
- Also, opening a new application is done using DVapp_start(). From
- the DVGLUE documentation:
- "This function is known to cause lockups under DV 2.00 (6-16-87).
- Use at your own risk (though I would appreciate hearing from you
- which version (and date) you are using and whether or not it
- worked). [Ralph Brown]"
- I have used this with DV 2.4 without problems, your mileage may
- vary.
-
- Comments
-
- The CRONTAB file is opened when CRON begins and is left open while
- CRON is running. Therefore it is HIGHLY RECOMMENDED that you also
- load SHARE.EXE so one doesn't accidently deleted the file as this
- would have highly unpredictable results. I use the timer functions
- of DV so the amount of time spent in CRON is minimal. With a 3 line
- CRONTAB file which executes commands once per day, and some once per
- hour, my machine uses only about 1 minute / day for the CRON
- process. Each minute, the first thing done is a check on CRONTAB to
- see whether it's been modified. If it has, it is re-read. You will
- note that there is no year entry in the CRONTAB file. This means
- that a CRONTAB entry will never expire. If you set it to a certain
- date (say 12 December) then it will execute only once per year.
-
- I have been using this program for about one week and have tried
- every parameter but I cannot guarentee this will not crash. If it
- does, or you have any other problems, please mail me at
-
- Internet:
- noesis@ucscb.ucsc.edu
- kyley@cats.ucsc.edu
- CompuServe:
- 72125,1533
-
-
- Technical Stuff
-
- This program was compiled with Turbo C 2.0 using the small memory
- model and optimization set to 'size'. I've heard it said "never set
- optimization to size" and always believed it until now. I felt there
- was little speed gain to be had.
-
- I tried my best to keep this thing small, and am very happy with the
- 19K result. If you see somewhere that the code can be optimized
- please let me know.