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:
Gmer4Lfe
2026-05-23 21:03:52 -04:00
parent 0e13d8772d
commit 8383306831
@@ -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.