|
33 | 33 |
|
34 | 34 | // Check whether another instance of this script is already running |
35 | 35 | $lockFile = $conf['temppath'] . $conf['fs_div'] . '.ispconfig_cron_lock'; |
36 | | -if (is_file($lockFile)) { |
| 36 | +if(is_file($lockFile)) { |
37 | 37 | clearstatcache(); |
38 | | - |
39 | | - // Maybe we hit a deadlock and the lock file is no longer relevant |
40 | | - if(filemtime($lockFile) > time() - 86400) { // 86400 seconds = 1 day |
41 | | - if($conf['log_priority'] <= LOGLEVEL_WARN) print @date('d.m.Y-H:i').' - WARNING - The cron lock file is older than one day.' . "\n"; |
42 | | - exit; |
43 | | - } |
44 | | - |
45 | | - // Check if the process id we have in the lock file is still present |
| 38 | + |
| 39 | +// Check if the process id we have in the lock file is still present |
46 | 40 | $pid = trim(file_get_contents($lockFile)); |
47 | 41 | if(preg_match('/^[0-9]+$/', $pid)) { |
48 | | - if(file_exists('/proc/' . $pid)) { |
49 | | - 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"; |
50 | | - exit; |
| 42 | + if(is_dir('/proc/' . $pid)) { |
| 43 | + if(file_exists('/proc/' . $pid . '/cmdline')) { |
| 44 | + if(strpos(file_get_contents('/proc/' . $pid . '/cmdline'), 'cron.php') !== false) { |
| 45 | + 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"; |
| 46 | + exit; |
| 47 | + } else { |
| 48 | + 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"; |
| 49 | + } |
| 50 | + } else { |
| 51 | + if(filemtime($lockFile) < time() - 86400) { |
| 52 | + 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"; |
| 53 | + } else { |
| 54 | + 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"; |
| 55 | + exit; |
| 56 | + } |
| 57 | + } |
51 | 58 | } |
52 | 59 | } |
53 | 60 | 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 commit comments