|
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 | + } |
| 58 | + } else { |
| 59 | + 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"; |
| 60 | + |
51 | 61 | } |
52 | 62 | } |
53 | | - 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"; |
54 | 63 | } |
55 | 64 |
|
56 | 65 | // Set Lockfile |
|
69 | 78 |
|
70 | 79 |
|
71 | 80 | // Load required base-classes |
72 | | -$app->uses('modules,ini_parser,file,services,getconf,system,cron,functions'); |
| 81 | +$app->uses('modules,ini_parser,file,services,getconf,system,cron,functions,plugins'); |
73 | 82 | $app->load('libdatetime,cronjob'); |
74 | 83 |
|
75 | 84 | // read all cron jobs |
|
0 commit comments