With a fair few extensions now tapping into the scheduler, I thought it useful to put together a guide on how to get that up and running. I'm not going to go into the details of cron itself, but if you fancy some extra reading, I'd recommend checking out this wikipedia article about cron.
Why should I care?
Quite simply, a growing list of extensions now support handling certain functions automatically for you, completely behind the scenes. Wondering why fof/drafts
'scheduled drafts' are not posting, or fof/best-answer
'remind users to set a best answer after X days' does not fire? That'll be because they will setup themselves with the scheduler service, but without a one-liner cron job, nothing will happen!
What extensions currently use the scheduler?
Know of any more? Let me know and I'll add them to this list!
Ok, let's get this setup!
Easy! Most (if not all) linux distros either come with, or can have cron installed. For example, on Debian
and Ubuntu
based systems, install cron like this:
$ sudo apt-get update
$ sudo apt-get install cron
Once you have cron installed, let's create the one and only entry you need for Flarum:
$ crontab -e
This will open the cron editor. You may or may not have other entries there. Add this line, and remember to leave an empty line at the bottom!
* * * * * cd /path-to-your-project && php flarum schedule:run >> /dev/null 2>&1
You may need to experiment with the path to php
, etc
* * * * *
tells cron to run your command every minute
cd /path-to-your-project && php flarum schedule:run
simply says php flarum ......
you've likely seen this many times before!
>> /dev/null 2>&1
simply suppresses any output from the command (you won't need this anyway)
Voila! Now any extension that registers a task to run, anything from every minute to daily, monthly, yearly - whatever - will now run on your server.
This post will likely be a work-in-progress for a while! Feel free to contribute anything you feel relevant!