home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / videotlk.zip / SAMPLES / CAM / CRON.CMD < prev    next >
OS/2 REXX Batch file  |  1997-01-08  |  2KB  |  61 lines

  1. /* CRON.CMD -- cheap UNIX cron clone for OS/2
  2.    Jeroen Hoppenbrouwers (hoppie@kub.nl), October 1994 */
  3.  
  4. say 'Hello world'
  5. beep
  6.  
  7. signal on halt
  8. call rxFuncAdd 'sysSleep', 'rexxUtil', 'sysSleep'
  9.  
  10. say 'CRON started' date() time()
  11. do forever
  12.  
  13.   /* determine current time and date */
  14.   currMin = time('m')-time('h')*60
  15.   currHour = time('h')
  16.   today = date('o')
  17.   parse var today currYear '/' currMonth '/' currDay
  18.   today = date('w')
  19.   currDow = wordPos(today,'Sunday Monday Tuesday Wednesday Thursday Friday Saturday')-1
  20.  
  21.   /* Parse and check the crontab file */
  22.   line = lineIn('crontab',1)
  23.   do while line<>''
  24.     parse var line minutes hours days months dows command
  25.     isMin   = matches(minutes, currMin)
  26.     isHour  = matches(hours, currHour)
  27.     isDay   = matches(days,currDay)
  28.     isMonth = matches(months,currMonth)
  29.     isDow   = matches(dows,currDow)
  30.     if isMin & isHour & isDay & isMonth & isDow
  31.       then do
  32.         say currMin'm' currHour'h' currDay'd' currMonth'm' currDow'w:' line
  33.         "@detach" command
  34.       end
  35.     line = lineIn('crontab')
  36.   end
  37.   call stream 'crontab','c','close'
  38.   call sysSleep 60-(time('s')-time('m')*60)
  39.  
  40. end  /* main loop */
  41.  
  42. matches:
  43. args = arg(1)
  44. if args='*' then return 1
  45. matched = 0
  46. parse var args value ',' args
  47. do while value<>''
  48.   if value=arg(2) then matched = 1
  49.   parse var value from '-' to
  50.   if from<=arg(2) & arg(2)<=to then matched = 1
  51.   parse var args value ',' args
  52. end
  53. return matched
  54.  
  55. halt:
  56. say ''
  57. say 'CRON stopped' date() time()
  58.  
  59. /* end of file */
  60.  
  61.