%%s 0/0/0 %%d D 1.1 28-Feb-86 14:28:19 dpm 1 0 %%c First distribution of CRON to the general public. %%T %%I 1 #-h- cron.r 4145 asc 28-feb-86 14:28:05 dpm (dave martin) #-h- defns 23 asc 19-oct-82 16:12:54 sventek (joseph sventek) define(Minute_delta,5) #-h- main 2888 asc 05-nov-82 12:22:03 sventek (joseph sventek) DRIVER(cron) # main routine for `cron' utility character buf(MAXLINE), pid(PIDSIZE), tail(4), file(FILENAMESIZE), date(10), time(9), path(arith(3,*,FILENAMESIZE)), image(FILENAMESIZE) integer now(7), today, i, junk, level, nmatch integer wkday, readln, matchs, spawn, sleep, gitocf, assign, remove, loccom filedes ifd, ofd filedes open, create string infile "~usr/crontab" string logfil "~usr/cron.log" string head "~tmp/cron" string shsufx ".sh" string opnerr "Error creating temporary file: " string spnerr "Error spawning image in background: " string suffix IMAGE_SUFFIX string shstr "sh" string s1 "sh -c " string s2 " ; rm " level = 0 repeat { call close(ERROUT) call getnow(now) i = 60 * (arith(Minute_delta,-,1) - mod(now(5), Minute_delta)) + 60 - now(6) junk = sleep(i) call getnow(now) today = wkday(now(2), now(3), now(1)) - 1 junk = assign(logfil, ERROUT, APPEND) call fmtdat(date, time, now, LETTER) if (level >= 1000) level = 0 junk = gitocf(level, tail, 4, 10, 3, '0') # generate 3-digit rolling no ifd = open(infile, READ) if (ifd == ERR) next call concat(head, tail, file) call concat(file, shsufx, file) ofd = create(file, WRITE) if (ofd == ERR) { call putlin(opnerr, ERROUT) call putlnl(file, ERROUT) call close(ifd) next } nmatch = 0 # initialize counter while (readln(buf, ifd) != EOF) # get next entry { i = 1 call skipbl(buf, i) if (buf(i) == '#' | buf(i) == '@n') # commented or empty entry next if (matchs(now(5), buf, i) == YES) # minutes match andif (matchs(now(4), buf, i) == YES) # hour matches andif (matchs(now(3), buf, i) == YES) # day of month matches andif (matchs(now(2), buf, i) == YES) # month of year matches andif (matchs(today, buf, i) == YES) # day of week matches { call skipbl(buf, i) call putlin(buf(i), ofd) # save the command line nmatch = nmatch + 1 # increment count of commands if (nmatch == 1) # date banner needed in log file { call putch('@n', ERROUT) call putlin(date, ERROUT) call putch(' ', ERROUT) call putlnl(time, ERROUT) } call putlin(buf(i), ERROUT) } } call close(ifd) call close(ofd) if (nmatch > 0) # something to do { i = 1 call stcopy(s1, 1, buf, i) call stcopy(file, 1, buf, i) call stcopy(s2, 1, buf, i) call stcopy(file, 1, buf, i) call remark(buf) call impath(path) if (loccom(shstr, path, suffix, image) != BINARY) call remark("Error locating image file for shell.") else if (spawn(image, buf, pid, BACKGR) == ERR) { call putlin(spnerr, ERROUT) call putlnl(image, ERROUT) } level = level + 1 } else junk = remove(file) # delete the file } DRETURN end #-h- matchs 626 asc 19-oct-82 16:12:57 sventek (joseph sventek) integer function matchs(value, buf, i) integer value, i, stat, first, last integer ctoi character buf(ARB) call skipbl(buf, i) stat = NO if (buf(i) == '*') { stat = YES i = i + 1 } else { repeat { first = ctoi(buf, i) if (buf(i) != '-') last = first else { i = i + 1 last = ctoi(buf, i) } if (value >= first & value <= last) stat = YES if (buf(i) == ',') i = i + 1 } until (buf(i) == ' ' | buf(i) == '@t') } #stat = YES #for ( call skipbl(buf, i); buf(i) != EOS; i=i+1) # if (buf(i) == ' ' | buf(i) == '@t') # break return(stat) end #-h- readln 300 asc 05-nov-82 12:18:46 sventek (joseph sventek) integer function readln(buf, fd) character buf(ARB) filedes fd integer n, l integer getlin n = 1 repeat { l = getlin(buf(n), fd) if (l == EOF) return(EOF) n = n + l - 2 if (n <= 0) break if (buf(n) != '@@') break buf(n) = ' ' n = n + 1 buf(n) = EOS } return(n) end #-h- cron.fmt 1241 asc 28-feb-86 14:28:06 dpm (dave martin) .so ~bin/manhdr .hd cron (sys) 24-Jan-84 clock daemon .sy ~bin/cron .ds CRON executes commands at specified dates and times according to the instructions in the file ~usr/crontab. Since CRON never exits, it should only be executed once, usually when the system is booted. .sp Crontab consists of lines of six fields each. The fields are separated by spaces or tabs. The first five are integer patterns to specifiy: .sp .nf .in +16 minute 0-59 hour 0-23 day of the month 1-31 month of the year 1-12 day of the week 1-7 (1 => Monday) .sp .in -16 .fi Each of these patterns may contain a number in the range above; two numbers separated by a minus meaning a range inclusive; a list of numbers separated by commas meaning any of the numbers; or an asterisk meaning all legal values. The sixth field is a string that is executed by the Shell at the specified times. .sp CRONTAB is examined by CRON at periodic intervals, usually between 1 and 10 minutes. .ex .ce 0,10,20,30,40,50 9-17 * * 1-5 command .sp .fi Execute command every 10 minutes from 9AM-5PM Monday-Friday. .sp .ce 23 50 * * 5 command .sp Execute command at 10 minutes before midnight every Friday. .fl ~usr/crontab .br ~usr/cron.log .au Joe Sventek #-h- cron.com 401 asc 28-feb-86 14:28:07 dpm (dave martin) $ cron := st_bin:cron.exe $ if f$search("st_usr:cron.exe") .nes. "" then cron := st_usr:cron.exe $! $ run 'cron' - /output=nla0: - /input=nla0: - /error=nla0: - /process_name="cron" - /prio=4 - /subp=10 - /file=75 - /buffer=20480 - /page=51200 - /queue=40 - /ast_limit=10 - /uic=[10,1] - /priv=(nosame,sysprv,sysnam,grpnam,group,tmpmbx,world,netmbx,oper,- syslck,exquota,detach,setprv) #-h- crontab 66 asc 28-feb-86 14:28:07 dpm (dave martin) #minute hour day-of-month month-of-year day-of-week shell-command %%E 1