Separate file for new cron jobs option
authorJamie Cameron <jcameron@webmin.com>
Mon, 27 Apr 2009 01:15:13 +0000 (01:15 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 27 Apr 2009 01:15:13 +0000 (01:15 +0000)
cron/CHANGELOG
cron/config.info
cron/cron-lib.pl

index 310f709..04dd9bc 100644 (file)
@@ -35,3 +35,5 @@ Disable time and day lists when 'All' is selected, to indicate that they are un-
 ---- Changes since 1.440 ----
 The search form for jobs is always visible, even when there are not too many jobs to show.
 Converted commands in the module's API file to POD format, and added more details about each function.
+---- Changes since 1.480 ----
+Added a Module Config option to add new cron jobs to a specific file, like /etc/cron.d/webmin, instead of users' personal crontab files.
index 56ae889..b5da541 100644 (file)
@@ -8,6 +8,7 @@ match_mode=Find job processes by,1,1-Command only,0-Command and arguments
 match_user=Match usernames when finding job processes?,1,1-Yes,0-No
 kill_subs=Kill sub-processes when terminating jobs?,1,1-Yes,0-No
 hourly_only=Only allow jobs to be at most hourly?,1,0-No,1-Yes
+add_file=Add new jobs to file,3,User's regular crontab file
 line2=System configuration,11
 cron_dir=Crontab Directory,0
 cron_get_command=Command to read a user's cron job,0
index 0994ff9..266709c 100644 (file)
@@ -314,7 +314,14 @@ sub create_cron_job
 {
 &check_cron_config_or_error();
 &list_cron_jobs();     # init cache
-if ($config{'single_file'} && !$config{'cron_dir'}) {
+if ($config{'add_file'}) {
+       # Add to a specific file, typically something like /etc/cron.d/webmin
+       $_[0]->{'type'} = 1;
+       local $lref = &read_file_lines($config{'add_file'});
+       push(@$lref, &cron_job_line($_[0]));
+       &flush_file_lines($config{'add_file'});
+       }
+elsif ($config{'single_file'} && !$config{'cron_dir'}) {
        # Add to the single file
        $_[0]->{'type'} = 3;
        local $lref = &read_file_lines($config{'single_file'});
@@ -1065,7 +1072,8 @@ based on the username.
 =cut
 sub cron_file
 {
-return $_[0]->{'file'} || "$config{'cron_dir'}/$_[0]->{'user'}";
+return $_[0]->{'file'} || $config{'add_file'} ||
+       "$config{'cron_dir'}/$_[0]->{'user'}";
 }
 
 =head2 when_text(&job, [upper-case-first])