diff --git a/core/BackgroundJobs/CleanupBackgroundJobsJob.php b/core/BackgroundJobs/CleanupBackgroundJobsJob.php index 6242941eed1ba..b4aa9d79e5efa 100644 --- a/core/BackgroundJobs/CleanupBackgroundJobsJob.php +++ b/core/BackgroundJobs/CleanupBackgroundJobsJob.php @@ -47,11 +47,9 @@ private function reapCrashedJobs(): void { if ($job->serverId !== $currentServerId) { continue; } - $output = []; - $result = 0; - exec('ps -p ' . escapeshellarg((string)$job->pid) . ' -o cmd', $output, $result); - if (count($output) === 1 && current($output) === 'CMD' && $result === 1) { - // Process doesn't exists anymore + $processExists = posix_kill($job->pid, 0) || posix_get_last_error() === 1 /* EPERM */; + if (!$processExists) { + // Process doesn't exist anymore $maxDuration = (new DateTimeImmutable())->diff($job->startedAt); $maxDuration = ($maxDuration->days * 24 * 60 * 60 * 1000) diff --git a/lib/private/BackgroundJob/JobRuns.php b/lib/private/BackgroundJob/JobRuns.php index 51145a9c1947c..8ff7a016271c4 100644 --- a/lib/private/BackgroundJob/JobRuns.php +++ b/lib/private/BackgroundJob/JobRuns.php @@ -63,7 +63,6 @@ public function finished(int|string $runId, int $duration, int $memoryPeakUsage, public function deleteBefore(int $timestamp): int { $beforeSnowflake = $this->snowflakeGenerator->minForTimeId($timestamp); - $beforeSnowflake = '91480652934574081'; $qb = $this->connection->getQueryBuilder(); $result = $qb ->delete(self::TABLE)