27 lines
584 B
PHP
Executable File
27 lines
584 B
PHP
Executable File
<?php
|
|
$fileName = __DIR__ . '/cron.txt';
|
|
$pidFile = __DIR__ . '/cronPid.txt';
|
|
$pidFilePointer = fopen($pidFile, "w+");
|
|
if (flock($pidFilePointer, LOCK_EX | LOCK_NB)) {
|
|
if (file_exists($fileName) && filesize($fileName)>0) {
|
|
unlink($fileName);
|
|
}
|
|
|
|
while (true) {
|
|
if(!file_exists($pidFile))
|
|
exit;
|
|
|
|
if (file_exists($fileName) && filesize($fileName)>0) {
|
|
$cronFile = fopen($fileName, "r+");
|
|
while (($buffer = fgets($cronFile, 4096)) !== false) {
|
|
shell_exec($buffer);
|
|
}
|
|
|
|
ftruncate($cronFile, 0);
|
|
fclose($cronFile);
|
|
}
|
|
sleep(2);
|
|
clearstatcache();
|
|
}
|
|
}
|