Jump to content

[request] Give System Scheduler the ability to run tasks using cron

t vago

Recommended Posts

Right now, I see that the System Scheduler uses a cooperative multitasking approach using page loads to fire off scheduled tasks. I can also see that individual tasks have the option of being run using cron instead of by System Scheduler, by using a tailored curl string for use with crontab.

Could it be possible to code in something that allows the System Scheduler itself to be run via cron instead of via page loads, in a similar manner as with the individual tasks? Some sort of on/off switch in the system settings to control this? You could decrease the potential loading each user sees when they visit the board using this approach, for they would not run the risk of having the board run potentially resource-intensive tasks (like building the weekly email digest of the board's activity). It'd also be better with those of us using a web hosting service that only allows up to 10 cron tasks to be run per account.

I made a stupidly simple php file which is fired off by cron, but I would have to manually edit it each time I wanted to change scheduling frequencies, or add or remove a task. It'd be nice to use the existing functionality of the ACP to change task frequencies or add tasks or remove tasks, and have the ability to fire all enabled tasks using cron instead of page loads.

Link to comment
Share on other sites

I'm thinking of creating a task of my own that would do what I want. My idea would be to add a tinyint field to the taskmanager table for marking whether or not a given task could be a cron job. My proposed task would then be called using curl from cron. It would access the taskmanager table to figure out what tasks to run (next-run timestamp < time(), cronjob = yes, and enabled = no), and then it would actually call said tasks and update their next-run timestamps.

This approach would have the advantage of not actually modifying the underlying board software. That would make this proposal portable, I would think. Throw in an separate interface to mark taskmanager tasks as cron tasks or normal tasks, and a small installer that would actually make the column add for the taskmanager table in addition to adding itself to the taskmanager table, and it could even be offered to other people here. They'd just have to set up their crontab (or cron manager, or whatnot) to run this one task.

Of course, this proposed task could never be itself called by the System Scheduler, for that would not make sense and would possibly lead to system instability.

It sounds a little clunky, but I think this could be a good workaround. Thoughts? Suggestions? Ideas?

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...