home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Big Blue Disk 51
/
bbd51.zip
/
SCHEDULE.TXT
< prev
next >
Wrap
Text File
|
1990-11-13
|
14KB
|
361 lines
|A╔═══════╦══════════════════════════════════════════════════════════════╦═══════╗
|A║ ^0Tools |A║ ^1 SCHEDULE |A ║^0 Tools|A ║
|A╚═══════╩══════════════════════════════════════════════════════════════╩═══════╝
^Cby
^CMichael West
SCHEDULE is a batch-file utility that allows you to set up and run programs
and DOS commands based on a number of time factors.
With SCHEDULE you can run programs and commands based on:
The day of the week (Sunday, Wednesday etc.)
The day of the month
The day of the quarter
The specific day of the year (either in Gregorian or Julian format)
The number of elapsed days since the last time the commands were run
^1 Editor's note: Since SCHEDULE is intended to be used in batch files, it is
^1 not runnable from within the Big Blue Disk menu. You may use this
^1 utility from the DOS command-line or in batch files outside of BBD.
^1Batch files^0
Batch files are special files which contain lists of commands. When you run a
batch file, each command in the list is executed just as if you had typed them
from the keyboard. You can record all the steps necessary to perform some
common task in one batch file, then you will only have to remember the name of
this batch file rather than each individual step. Batch files are valuable
tools for novices and experienced computer users. For more information about
batch files, consult your MS-DOS reference manual.
^1How SCHEDULE works^0
Let's look at an example of how SCHEDULE can be used to make batch files even
more useful:
SCHEDULE D 3/1
IF ERRORLEVEL 2 GOTO No_Backup
ECHO Backing up files
BACKUP C:*.COM A: /s
GOTO End
:No_Backup
ECHO No backup performed
:END
In this example we will backup all the files on drive C that have a COM
extension on March 1st. SCHEDULE takes two operands (with one exception to be
discussed later). The first operand, D in this case, tells SCHEDULE that the
second operand is a month and day. When SCHEDULE runs it will check the date
in the computer and if it is NOT March 1st SCHEDULE will return ERRORLEVEL 2.
If the date IS March 1st, SCHEDULE returns an ERRORLEVEL 1. You can use the
IF-ERRORLEVEL statement to bypass commands EXCEPT when the date you specify
occurs.
Here's another example:
SCHEDULE J 60
IF ERRORLEVEL 2 GOTO No_Backup
ECHO Backing up files
BACKUP C:*.COM A: /s
GOTO End
:No_Backup
ECHO No backup performed
:End
This is the same logic as the first example except that the first operand is a
J indicating that the second operand is a Julian date. In this case we back
up all our COM files on the 60th day of the year (which is also March 1st
except in leap years).
And that's all there is to it! SCHEDULE returns only two error codes, 1 if
the date matches the date in the command line and 2 if it doesn't.
Here is the complete list of SCHEDULE options:
SCHEDULE D MM/DD - Checks the current month and day against the month and
day in the second operand.
Example: SCHEDULE D 9/14 - Returns ERRORLEVEL 1 on Sept. 14
else returns ERRORLEVEL 2.
SCHEDULE J NNN - Checks the current Julian date against the Julian date
in the second operand.
Example: SCHEDULE J 100 - Returns ERRORLEVEL 1 on the 100th day of the
year (April 10), else returns ERRORLEVEL 2.
SCHEDULE M NN - Checks the current day of the month against the one or
two digit date specified in the second operand.
Example: SCHEDULE M 9 - Returns ERRORLEVEL 1 if the current date is the
ninth day of the month (any month), else returns ERRORLEVEL 2.
SCHEDULE M L - This option returns an ERRORLEVEL 1 if the current
date is the last day of any month, otherwise it
returns an ERRORLEVEL 2. Using this option allows you
to set up commands and programs that run at the end of
the month without reciting to yourself "Thirty days
hath September..."
SCHEDULE Q NN - This option is similar to SCHEDULE M NN but it is
based on the day of the quarter, instead of the month.
This option allows you to run commands and programs on
specific days within quarters.
Example: SCHEDULE Q 10 - Returns ERRORLEVEL 1 if the current date is the
tenth day of any quarter (Jan. 10, Apr. 10, Jul. 10 or Oct. 10),
otherwise returns an ERRORLEVEL 2.
SCHEDULE Q L - This option returns ERRORLEVEL 1 if the current date
is the last day of any quarter (Mar. 31, Jun. 30,
Sept. 30 or Dec. 31), otherwise it returns an
ERRORLEVEL 2. Using this option allows you to set
up commands and programs that run at the end of each
calendar quarter.
SCHEDULE W - This option (Weekday) is used when you want to run
commands or programs on a certain day of the week.
Option 2 should be one of the following abbreviations:
SUN, MON, TUE, WED, THU, FRI, SAT.
Example: SCHEDULE W TUE - Returns ERRORLEVEL 1 if the current date is a
Tuesday, otherwise returns an ERRORLEVEL 2.
^1Elapsed days option^0
In addition to the above options it is also possible to SCHEDULE events based
on the number of elapsed days since the last time another event (or the same
one) was run. Here's an example of how that works:
SCHEDULE E201 14
IF ERRORLEVEL 2 GOTO End
ECHO It's been fourteen days since we last ran CHKDSK
CHKDSK
:End
The first option is an elapsed day trigger. SCHEDULE allows for 256 triggers
(E1 to E256). In this case we have chosen to use trigger #201 (but we can use
any trigger we want for any purpose). Elapsed day triggers are stored on a
special file (more about this later).
The second operand (14) is the number of days in the elapsed period. In this
case we run CHKDSK if 14 or more days have elapsed since the last time we ran
some batch file using trigger #201.
To make the point a little clearer let's look at exactly what SCHEDULE does
when handling an elapsed day trigger.
1. SCHEDULE reads the trigger file. In the above example, SCHEDULE
checks the date stored in trigger #201.
2. SCHEDULE adds the second operand (14 in our example) to the date in
the trigger.
3. If the new date is less than the current date SCHEDULE returns an
ERRORLEVEL 2.
4. If the new date is greater than, or equal to, the current date,
SCHEDULE returns an ERRORLEVEL 1 AND (THIS IS IMPORTANT!) updates the
trigger with the current date.
So if our example were a batch file we run every day, CHKDSK would run when
fourteen or more days have elapsed since trigger #201 was set. At that time
trigger #201 would be reset to the current date so that trigger would be
reactivated again fourteen days later.
^1More on the triggers^0
You have 256 triggers to work with. Now you might think you need a lot of
triggers; for example if you used SCHEDULE three times in the same batch file,
or one time each in three different batch files you might think you need three
different triggers. But if the number of elapsed days is the same, you can
use the same trigger repeatedly. Here's an example of how to do it:
SAVECOM.BAT contains the following code:
SCHEDULE E8 21
IF ERRORLEVEL 2 GOTO No_Backup
BACKUP *.COM A: /s
:No_Backup
SAVEEXE.BAT contains the following code:
SCHEDULE E8 21
IF ERRORLEVEL 2 GOTO No_Backup
BACKUP *.EXE A: /s
:No_Backup
The first example backs up all COM files every 21 days. The second example
does the same thing for EXE files. Both batch files use the same trigger (8).
But how can you do this? Won't running the first example set trigger 8 every
21 days. Wouldn't setting trigger 8 keep the second example from working
properly?
No. Here's why: THE CHANGE IN A TRIGGER'S DATE TAKES EFFECT ONLY AFTER YOU'VE
USED THAT TRIGGER FOR THE LAST TIME ON A GIVEN DATE.
In the two examples above E8 would be set when the second file is run. If a
third file uses and sets E8 THAT would be the point where the trigger is set.
What this whole rigmarole means is that you can use a single trigger to
represent a series of elapsed days in more than one place. You can use
trigger 3 to mean 3 elapsed days in many batch files (or more than one spot in
a single file). You can use trigger 30 to represent 30 elapsed days (or 15,
or 92) throughout your system. The ability of a trigger to do double-duty
combined with 256 possible triggers gives you plenty to work with.
You may of course wonder how SCHEDULE knows you've used a trigger for the last
time. After all you may use it one time one day and five times on another.
Well the answer is rather technical and I won't bore you with it. You'll just
have to trust me when I say that SCHEDULE knows when you've used a trigger for
the last time on a given date.
^1Setting and viewing elapsed day triggers^0
You can set an elapsed day trigger, either by specifying a specific date such
as Aug. 2, 1991 or by specifying a date relative to the current date.
Example: SCHEDULE S118 9/14/90 - This sets trigger 118 to Sept. 14, 1990.
Example: SCHEDULE S5 3/9/05 - This sets trigger to 5 to Mar. 9, 2005.
When setting a trigger the year must be a two digit number between 80 (1980)
and 79 (2079). SCHEDULE makes the necessary adjustment.
You can also use a relative date adjustment:
Example: SCHEDULE S61 * - This sets trigger 61 to the current date.
Example: SCHEDULE S19 *+10 - Sets trigger 19 to the current date plus 10
days.
Example: SCHEDULE S110-365 - Sets trigger 110 to the current date minus
one year.
You can set triggers in batch files or at the DOS prompt. Setting triggers in
batch files allows you some flexibility in running your programs. For example
here's a batch file I run at home every night before hitting the off switch
(SHUTDOWN.BAT).
ECHO OFF
SCHEDULE E2 90
IF ERRORLEVEL 2 GOTO End
ASK "Run Spinrite? " yn
IF ERRORLEVEL 2 GOTO Reset
SPINRITE BATCH BLANKING AUTOEXIT AUTOREPORT
GOTO End
:Reset
SCHEDULE E2 *-90
:End
PARK
Every 90 days I'm prompted to run Spinrite. If I run Spinrite trigger #2 is
left set to the current date. If I don't run Spinrite I branch to Reset and
set trigger 2 down by 90 days. This causes SHUTDOWN.BAT to prompt me again
the following day. As soon as I do run Spinrite SHUTDOWN.BAT quits pestering
me for another 3 months.
Finally, you can view the date in a specific trigger by specifying the trigger
number alone:
Example: SCHEDULE S28 - Displays the date currently stored in trigger 28.
The earliest possible date is 1/1/80.
^1The trigger file^0
The elapsed date trigger file is SCHEDULE.TRG. It is created the first time a
trigger is used (either accessed, set or displayed). SCHEDULE searches for
SCHEDULE.TRG by using the following steps:
1. SCHEDULE searches the current directory.
2. If SCHEDULE.TRG isn't found in the current directory
SCHEDULE searches each directory in the path.
3. If SCHEDULE.TRG isn't found in the path then the file
is created in the current directory.
When you first install SCHEDULE change to a directory that is in your path and
type SCHEDULE S1. This will force SCHEDULE to create the trigger file where
SCHEDULE can always find it.
When SCHEDULE.TRG is first created, all dates will be initialized to 1/1/80.
^1Some final notes^0
Errors: If SCHEDULE detects an error, it will return an ERRORLEVEL 2 for all
operations except when setting a date. Setting a date (the S
operation) always returns an ERRORLEVEL 0.
Returning an ERRORLEVEL 2 means that commands won't be executed
because of an error.
Case: Despite the examples above SCHEDULE is not case sensitive.
^1A final example^0
This last example shows how you can use SCHEDULE to run GOAL TENDER every day
when you first start your computer:
ECHO OFF
REM Check trigger #5 to see if this is the first startup of the day.
REM If this is the first startup then display a random goal.
SCHEDULE E5 1
IF ERRORLEVEL 2 GOTO END_BATCH
GOAL -R -F SAMPLE
REM Set trigger 5 to today so that only one goal will be displayed a day.
SCHEDULE S5 * >NUL
:END_BATCH
This file is included on the disk as RUNGOAL.BAT. You may either add these
lines to the end of your AUTOEXEC.BAT file, or execute RUNGOAL as the last
line of your AUTOEXEC.BAT file. In either case, you may change the trigger
number to any of the 256 triggers available.
Use a standard text editor or the CATT utility to append this example to your
AUTOEXEC.BAT file. Always make a backup copy of your AUTOEXEC.BAT file before
making any changes!
^1Outside BBD^0
To run this program outside ^1Big Blue Disk^0, type: ^1SCHEDULE^0.
DISK FILES THIS PROGRAM USES:
^FSCHEDULE.EXE