home *** CD-ROM | disk | FTP | other *** search
/ ftp.madoka.org / 2014.12.ftp.madoka.org.tar / ftp.madoka.org / pub / plum / 1.x / plum11.lzh / plum11 / cron.plm < prev    next >
Text File  |  1997-08-28  |  915b  |  30 lines

  1. package cron;
  2.  
  3. $_ = 'cron';
  4.  
  5. sub main_loop {
  6.   local($userno) = @_;
  7.   local(@time, $now, $regex, $str, $date, $time, $exec, $pid);
  8.   @time = localtime(time);
  9.   $now = sprintf('%04d/%02d/%02d %02d:%02d:%02d', $time[5] + 1900, $time[4] + 1, $time[3], $time[2], $time[1], $time[0]);
  10.   foreach $last (&'array($cronlist[$userno])) {
  11.     $regex = &'regex($last);
  12.     next if $now =~ /$regex/;
  13.     $cronlist[$userno] = &'remove($cronlist[$userno], $last);
  14.   }
  15.   foreach $cron (&'property($userno, 'cron')) {
  16.     ($date, $time, $exec) = split(/\s+/, $cron, 3);
  17.     $str = $date . ' ' . $time;
  18.     $regex = &'regex($str);
  19.     next unless $now =~ /$regex/;
  20.     $addlist[$userno] = &'add($addlist[$userno], $str);
  21.     next if &'exist($cronlist[$userno], $str);
  22.     $pid = fork;
  23.     if (defined($pid) && $pid == 0) {
  24.       exec($exec);
  25.     }
  26.   }
  27.   $cronlist[$userno] = &'add($cronlist[$userno], &'array($addlist[$userno]));
  28. }
  29.  
  30.