* Declarative specification of the system cron jobs. Ideally

this would abstract over the Crontab syntax though.

svn path=/nixos/trunk/; revision=10447
This commit is contained in:
Eelco Dolstra 2008-02-01 12:01:27 +00:00
parent 7521d6c49a
commit 9f62e1a6a5
3 changed files with 47 additions and 9 deletions

View File

@ -528,6 +528,24 @@
};
cron = {
systemCronJobs = mkOption {
default = [];
example = [
"* * * * * test ls -l / > /tmp/cronout 2>&1"
"* * * * * eelco echo Hello World > /home/eelco/cronout"
];
description = ''
A list of Cron jobs to be appended to the system-wide
crontab. See the manual page for crontab for the expected
format.
'';
};
};
ttyBackgrounds = {
enable = mkOption {

View File

@ -1,15 +1,35 @@
{cron}:
{pkgs, config}:
let
systemCronJobs = config.services.cron.systemCronJobs;
systemCronJobsFile = pkgs.writeText "system-crontab" ''
SHELL=${pkgs.bash}/bin/sh
PATH=${pkgs.coreutils}/bin
MAILTO=
${pkgs.lib.concatStrings (map (job: job + "\n") systemCronJobs)}
'';
in
{
name = "cron";
job = "
description \"Cron daemon\"
extraEtc = [
# The system-wide crontab.
{ source = systemCronJobsFile;
target = "crontab";
mode = "0600"; # Cron requires this.
}
];
start on startup
stop on shutdown
job = ''
description "Cron daemon"
respawn ${cron}/sbin/cron -n
";
start on startup
stop on shutdown
respawn ${pkgs.cron}/sbin/cron -n
'';
}

View File

@ -78,7 +78,7 @@ let
# Cron daemon.
(import ../upstart-jobs/cron.nix {
inherit (pkgs) cron;
inherit config pkgs;
})
# Name service cache daemon.