home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
daily.zip
/
DAILY.CMD
Wrap
OS/2 REXX Batch file
|
1993-10-16
|
3KB
|
90 lines
/* */
/*
This file = Daily.cmd
Author = Alan Thorogood
Date = 7 October 93
Version = 1.0
Dedication:
This REXX procedure is public domain and may be freely distributed, copied and modified.
Please do not delete the author name. I may be contacted on Compuserve:100014,3633.
Objective:
Waits until a specified time each day and then executes a command.
The user presses control-break to stop the cycle.
The time and command are coded into the Init routine below.
There are near-zero CPU cycles wasted in serving the Wait routine.
The command may be any valid program name (DOS, OS/2, Windows),
.cmd, .bat etc. etc..
Anything OS/2 can run from its prompt will be executed.
This .cmd file will wait until the called program completes before re-scheduling the
next run. This means that if an error occurs and the called program waits for keyboard
input then another, similar, process will not start in 24 hours time.
BEWARE!!!
IF this utility is being used to run, say, a tape backup and the tape backup utility terminates
on completion AND it is being run over a weekend without attention THEN on Sunday it
will re-run the same backup with the Saturday tape still loaded in the drive.
To stop this happening you will need to write a REXX or DOS or Windows or PM procedure
that will wait for keyboard input on a Saturday or in all cases.
*/
Main:
Call Init
DO WHILE 1
Call Process
END
/* No close routine because the user Control-breaks */
Init:
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
/*************************************************************************
PUT YOUR TIME AND COMMAND BELOW HERE
**************************************************************************/
JobTime = '09:03:00' /* Code this with the start time in 24hr format */
Command = 'HELLO' /* Code this with the command to execute */
JobHH = LEFT(JobTime,2)
JobMM = SUBSTR(JobTime,4,2)
JobSS = RIGHT(JobTime,2)
JobSeconds = (JobHH * 60 * 60) + (JobMM * 60) + JobSS
Count = 0 /* used for information only on how many times
it has been executed */
/* Add the constant MidnightSeconds */
MidnightSeconds = 24 * 60 * 60
return
Process:
/* get the current time in hh:mm:ss */
CurrentTime = TIME()
CurrentHH = LEFT(CurrentTime,2)
CurrentMM = SUBSTR(CurrentTime,4,2)
CurrentSS = RIGHT(CurrentTime,2)
CurrentSeconds = (CurrentHH * 60 * 60) + (CurrentMM * 60) + CurrentSS
/* Calculate seconds to wait allowing for roll around the clock */
if JobSeconds > CurrentSeconds then WaitSeconds = JobSeconds - CurrentSeconds
else WaitSeconds = (MidnightSeconds - CurrentSeconds) + JobSeconds
if WaitSeconds = 0 then WaitSeconds = MidnightSeconds
say 'This daily wait routine written by Alan Thorogood Cserve ID:100014,3633'
say 'Since this procedure started it has executed' Count 'times'
say 'This time it started waiting at' CurrentTime 'and is waiting for' JobTime
say 'to execute command:' Command
call SysSleep WaitSeconds
'CMD /C ' Command
Count = Count + 1
return