home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / jobsta.zip / JOBSTART.CMD < prev   
OS/2 REXX Batch file  |  1995-07-21  |  2KB  |  69 lines

  1. /*****************************************************************************/
  2. /*   JobStart.CMD    GWB 7/17/95                         */    
  3. /*                                                                           */
  4. /* Starts job1 every day at 9pm                                              */
  5. /*                                                                           */
  6. /*  1.1 - Accepts the time to start on the command line                      */
  7. /*  1.2 - Starts Job1 Weekdays at 9pm, Job2 Saturday at 9pm                  */
  8. /*  1.21- Did the help test a little simpler                                 */
  9. /*****************************************************************************/
  10.  
  11. call RxFuncAdd 'SysLoadFuncs' , 'RexxUtil',  'SysLoadFuncs'
  12. call SysLoadFuncs
  13.  
  14. secsday=60*60*24
  15. Ver="1.21 7/21/95 GWB"
  16. parse arg waittime debug .
  17. parse value waittime with hh ':' mm .
  18. interval=120
  19. job1='"Job1" /c d:\misc\hello.cmd'
  20. job2='"Job2" /c d:\misc\goodbye.cmd'
  21. job2day='Saturday'
  22. DayOff='Sunday'
  23. if pos('?',arg(1))>0 then
  24.   do
  25.     say "JobStart: Ver=" Ver " Usage is JobStart Start_Time"
  26.     say " Start_Time = Time of Day in HH:MM format to start, default is 9:00pm."
  27.     say " Job1 runs at Start_Time during weekdays, Job2 on Saturday, Never on Sunday"
  28.     say "  Good starting call is     JobStart 21:00             "
  29.     exit
  30.   end  
  31. if (debug="" | debug='?') then debug=0
  32. if (debug<>0) then
  33.   trace r
  34. if waittime="" then
  35.   secstart=secsday-60*60*3    /* Start monitoring at 9pm */
  36. else
  37.   do 
  38.     parse value waittime with hh ':' mm .
  39.     if hh > 24 then
  40.       hh=23
  41.     if mm > 60 then
  42.       mm=00 
  43.     secstart=60*( (60*hh) + mm)     /* Time of day in seconds to start */ 
  44.   end
  45. /*               Calculate when to start    */
  46. do forever
  47.   IF (Time("Seconds")> secstart) then
  48.     secstart = secstart + secsday         /* Already past the start time for today, start tomorrow */
  49.   secsdelay=secstart-Time("Seconds")    /* Number of seconds to wait */
  50.   say "Delay Seconds before starting=" secsdelay
  51.   if (debug<>0) then
  52.     do
  53.       say "Start the waiting"  
  54.       secsdelay=30
  55.     end
  56.   Call SysSleep(secsdelay)        /* Wait here until time to start job */
  57.   today=Date('W')
  58.   say today
  59.   if (today<>Dayoff & today <> Job2Day) then
  60.      '@Start'  job1 
  61.   else
  62.     if (today<>DayOff) then 
  63.       '@Start' job2
  64.   Call SysSleep(5)            /* Cut some slack */
  65. end /* do forever*/
  66.  
  67. return
  68.  
  69.