home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
1.x
/
plum12.lzh
/
plum12
/
cron.plm
< prev
next >
Wrap
Text File
|
1997-09-25
|
915b
|
30 lines
package cron;
$_ = 'cron';
sub main_loop {
local($userno) = @_;
local(@time, $now, $regex, $str, $date, $time, $exec, $pid);
@time = localtime(time);
$now = sprintf('%04d/%02d/%02d %02d:%02d:%02d', $time[5] + 1900, $time[4] + 1, $time[3], $time[2], $time[1], $time[0]);
foreach $last (&'array($cronlist[$userno])) {
$regex = &'regex($last);
next if $now =~ /$regex/;
$cronlist[$userno] = &'remove($cronlist[$userno], $last);
}
foreach $cron (&'property($userno, 'cron')) {
($date, $time, $exec) = split(/\s+/, $cron, 3);
$str = $date . ' ' . $time;
$regex = &'regex($str);
next unless $now =~ /$regex/;
$addlist[$userno] = &'add($addlist[$userno], $str);
next if &'exist($cronlist[$userno], $str);
$pid = fork;
if (defined($pid) && $pid == 0) {
exec($exec);
}
}
$cronlist[$userno] = &'add($cronlist[$userno], &'array($addlist[$userno]));
}