home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / cron.zip / cron.cmd next >
OS/2 REXX Batch file  |  1994-10-11  |  1KB  |  58 lines

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