Bug 24968 - Add Syspref controls for cronjobs
Summary: Add Syspref controls for cronjobs
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-24 14:59 UTC by Nick Clemens
Modified: 2022-02-02 11:34 UTC (History)
13 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2020-03-24 14:59:29 UTC
At the simplest it would be nice to have an on/off switch for any cronjob so that libraries can disable cronjobs as needed (during emergency closings etc.)

At the most advanced, it could offer the option of controlling all of the parameters for the cronjob, either using a syntax or a new administration area
Comment 1 Katrin Fischer 2020-03-24 15:01:14 UTC
+1
With mulitple instances on one server I'd really love that. Turning things off for just one instance is painful otherwise if you are using for-each.
Comment 2 Martin Renvoize 2020-03-25 12:10:38 UTC
Nice!
Comment 3 Magnus Enger 2020-03-25 12:18:08 UTC
(In reply to Nick Clemens from comment #0)
> At the most advanced, it could offer the option of controlling all of the
> parameters for the cronjob, either using a syntax or a new administration
> area

Or just use sysprefs for the parameters? Anyway, +1000 for this! :-)
Comment 4 Magnus Enger 2020-03-25 12:19:22 UTC
Duplicate of "Bug 7972 - GUI for Crons"?
Comment 5 David Cook 2020-10-27 22:33:50 UTC
(In reply to Magnus Enger from comment #4)
> Duplicate of "Bug 7972 - GUI for Crons"?

Hmm possibly. That bug seems to want to have full crontab access from the web, especially in regards to time scheduling, which sounds terrible to me as a vendor. But maybe I was misinterpreting the comments there.

Nick's suggestion seems to be more about just enabling/disabling and configuring scheduled tasks, which sounds good to me. It wouldn't actually affect cron's operation. Rather, it would affect the scripts executed by cron. Much more reasonable.

I suppose an easy way to bolt this on would be to expand Koha::Script (or a Koha::Script::* module). There could be an "is_enabled" function, and a "get_script_config" function. 

(Regarding Bug 7972, you could perhaps have some config that prevents the script from running during certain times. I think process_message_queue.pl runs every 15 minutes, but we've hard-coded our crontab to only run between 8:00-20:00 so emails don't go out late at night. With this feature, a library could designate their own "do not run" hours. Of course, this would only work if the cronjob is ordinarily set to run during those "do not run" hours, if that makes sense.)
Comment 6 David Cook 2020-11-19 05:51:44 UTC
I'm bumping into this with "/usr/share/koha/bin/cronjobs/membership_expiry.pl" where 1 library wants to send notices to only some categories.

In the past, we added a --category option, but that only worked when we set up cronjobs per-library instead of using koha-foreach. 

I think that I'm just going to use a local system preference here and a local code customization, but it would be useful for libraries to be able to define their own parameters via the web UI for this cronjob...

Really this is a "scheduled task" issue. Not just "cronjobs". In the future, we may have other schedulers in addition to the cron daemon. So whatever solution we come up with... it should be fairly extensible. 

Scheduled Task:
Name: MembershipExpiry
Args:
  Categories: ['Staff','Students','Administrators']
  Branches: ['CPL','MPL','QPL']
  Letter: 

A cronjob could fetch using my $task = ScheduledTask->GetByName('MembershipExpiry');

You could even arguably add "Min time interval" (maybe the cronjob runs every 15 minutes but you only want the job to run no faster than 1 time per hour) and "Last run" to try to control timing a bit... 

Anyway, just some thoughts
Comment 7 David Cook 2021-05-26 00:47:53 UTC
And now I'm noticing that unverified self-registrations aren't deleted by cleanup_database.pl unless you specify "--del-unv-selfreg X" and that's not a default for Koha, even though the default text for OPAC_REG_VERIFY says that unverified registrations "will expire shortly".
Comment 8 David Cook 2021-05-26 00:58:08 UTC
(In reply to David Cook from comment #6)

> Really this is a "scheduled task" issue. Not just "cronjobs". In the future,
> we may have other schedulers in addition to the cron daemon. So whatever
> solution we come up with... it should be fairly extensible. 
> 
> Scheduled Task:
> Name: MembershipExpiry
> Args:
>   Categories: ['Staff','Students','Administrators']
>   Branches: ['CPL','MPL','QPL']
>   Letter: 
> 

If we're going to use system preference though, it makes sense to group them in with their relevant areas... like "Self Registration".
Comment 9 Martin Renvoize 2021-05-26 10:26:38 UTC
I'd forgotten about this bug.. I'd love to see this move forward.. no idea if/when I'll have time to work on it.. but still think it's a great idea.