Skip to content
Snippets Groups Projects
Commit 13a54746 authored by Marius Burkard's avatar Marius Burkard
Browse files

- fixed cron lockfile check, fixes #5334

parent c8b6f257
No related branches found
No related tags found
No related merge requests found
......@@ -33,21 +33,28 @@ require SCRIPT_PATH."/lib/config.inc.php";
// Check whether another instance of this script is already running
$lockFile = $conf['temppath'] . $conf['fs_div'] . '.ispconfig_cron_lock';
if (is_file($lockFile)) {
if(is_file($lockFile)) {
clearstatcache();
// Maybe we hit a deadlock and the lock file is no longer relevant
if(filemtime($lockFile) > time() - 86400) { // 86400 seconds = 1 day
if($conf['log_priority'] <= LOGLEVEL_WARN) print @date('d.m.Y-H:i').' - WARNING - The cron lock file is older than one day.' . "\n";
exit;
}
// Check if the process id we have in the lock file is still present
// Check if the process id we have in the lock file is still present
$pid = trim(file_get_contents($lockFile));
if(preg_match('/^[0-9]+$/', $pid)) {
if(file_exists('/proc/' . $pid)) {
if($conf['log_priority'] <= LOGLEVEL_WARN) print @date('d.m.Y-H:i').' - WARNING - There is already an instance of server.php running with pid ' . $pid . '.' . "\n";
exit;
if(is_dir('/proc/' . $pid)) {
if(file_exists('/proc/' . $pid . '/cmdline')) {
if(strpos(file_get_contents('/proc/' . $pid . '/cmdline'), 'cron.php') !== false) {
if($conf['log_priority'] <= LOGLEVEL_WARN) print @date('d.m.Y-H:i').' - WARNING - There is already an instance of cron.php running with pid ' . $pid . '.' . "\n";
exit;
} else {
if($conf['log_priority'] <= LOGLEVEL_WARN) print @date('d.m.Y-H:i').' - WARNING - There is a process running with pid ' . $pid . ' but it seems not to be cron.php, continuing.' . "\n";
}
} else {
if(filemtime($lockFile) < time() - 86400) {
if($conf['log_priority'] <= LOGLEVEL_WARN) print @date('d.m.Y-H:i').' - WARNING - There is already an instance of cron.php running with pid ' . $pid . ' but process is older than 1 day. Continuing.' . "\n";
} else {
if($conf['log_priority'] <= LOGLEVEL_WARN) print @date('d.m.Y-H:i').' - WARNING - There is already an instance of cron.php running with pid ' . $pid . '.' . "\n";
exit;
}
}
}
}
if($conf['log_priority'] <= LOGLEVEL_WARN) print @date('d.m.Y-H:i').' - WARNING - There is already a lockfile set, but no process running with this pid (' . $pid . '). Continuing.' . "\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment