varaverk: fix cron format and permissions for dcron
Unraid's system crond is dcron (dillon's cron daemon 4.5), which reads /etc/cron.d/ for system crontabs WITHOUT a username field, and refuses to execute files that are group- or world-writable. vv_cron_rebuild() was writing "SCHED root bash ..." (with username field) and leaving the file world-writable (666), so dcron silently ignored every entry. Fixed: - Remove CRON_USER from the generated cron line format - chmod 0600 the cron file after writing it
This commit is contained in:
@@ -59,11 +59,15 @@ function vv_cron_rebuild(array $schedule): bool {
|
||||
$logDir = dirname($logFile);
|
||||
if (!is_dir($logDir)) mkdir($logDir, 0755, true);
|
||||
$flags = !empty($entry['log_enabled']) ? ' --log' : '';
|
||||
$lines[] = "{$entry['cron']} " . CRON_USER . " bash \"$script\"$flags >> \"$logFile\" 2>&1";
|
||||
$lines[] = "{$entry['cron']} bash \"$script\"$flags >> \"$logFile\" 2>&1";
|
||||
}
|
||||
$lines[] = "";
|
||||
|
||||
return file_put_contents(CRON_FILE, implode("\n", $lines)) !== false;
|
||||
// dcron (dillon's cron, Unraid's system crond) reads /etc/cron.d/ but refuses
|
||||
// world-writable files and does not use a username field in system crontab format.
|
||||
if (file_put_contents(CRON_FILE, implode("\n", $lines)) === false) return false;
|
||||
chmod(CRON_FILE, 0600);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Extract the suggested cron and label from a bash script header.
|
||||
|
||||
Reference in New Issue
Block a user