At the moment seems this CronJob create downtime to my server.
https://discuss.flarum.org/d/32955-flarum-scheduler-issues
Setup the Flarum scheduler using cron
Hello,
Unfortunately, I still have a problem with running this schedule. I have an account on shared hosting, and I know that cron generally works.
An example of another task that works for me:
/usr/local/bin/php82 /home/MY_USERNAME/domains/MY_DOMAIN/public_html/bin/console cron:daily
In the case of Flarum, the path looks like this:
/home/MY_USERNAME/domains/MY_DOMAIN/public_html/flarum/
I have set up cron in the panel like this:
- * * * * /home/MY_USERNAME/domains/MY_DOMAIN/public_html/flarum/ && /usr/local/bin/php82 flarum schedule:run
Unfortunately, it doesn't work. I also tried:
- * * * * /home/MY_USERNAME/domains/MY_DOMAIN/public_html/ && /usr/local/bin/php82 flarum schedule:run
Still nothing... I also tried according to the description:
- * * * * cd /home/MY_USERNAME/domains/MY_DOMAIN/public_html/ && php flarum schedule:run >> /dev/null 2>&1
and - * * * * cd /home/MY_USERNAME/domains/MY_DOMAIN/public_html/flarum && php flarum schedule:run >> /dev/null 2>&1
Unfortunately, without success... I have been struggling with this for two days now. Please help!
- Edited
Post can be deleted
hello. Please explain how to setup corn in cPanel. I'm try 100 times, but it's not work.
HarishSarker, what issue are you having? There is good documentation on how to setup a cronjob in Cpanel: https://docs.cpanel.net/cpanel/advanced/cron-jobs/
- Edited
HarishSarker if you run the command without the null
redirect part (from cd [...]
to [...] schedule:run
) in a shell on the server, what is the output? To verify the paths and syntax are correct.
I don't know whether cPanel has a CRON log output? If not you could also try replacing the null
redirect with a redirect to a temporary log file to try to get more information as to what happens when the CRON runs.
Is there really no username in the /home
path? I'm not very familiar with cPanel, maybe the site domain acts as the username, or it's a linux distro where the home
directory is not actually used like on other distros.
- Edited
IanM * * * * * cd /path-to-your-project && php flarum schedule:run >> /dev/null 2>&1
Is this still necessary or do extensions use another way to do their crons?
At least it looks like it's an old solution, because the admin panel doesn't show any info about the cronjob the admin has to create on the linux system and it can be activated without problems or any errors over the admin panel:
And even users can activate a cron without any problems/errors (without the cronjob above):
maxmoon fof/drafts does use the Flarum scheduling system, which requires cron (or some other system) to be set up to run the schedule:run
command. Clarification on these settings would probably be helpful to have in the extension's settings.
The admin settings not erroring is because they're simply setting values in the DB, which are used when determining whether to run a job or not in the scheduler.
The draft autosave is done on the client side (i.e. browser) and so has nothing to do with cron.
What exactly does drafts do in the background (on the server side) if drafts autosave is controlled by the client?
Will it be enough to trigger the scheduler every 3 hours, because every minute sounds a little bit like an overkill to me?
* */3 * * * cd /path-to-your-project && php flarum schedule:run
- Edited
maxmoon That would be publishing scheduled drafts once their time has arrived.
You should keep the cron job running every minute. The schedule:run
command already handles how often the registered schedules by extensions are ran - for example, drafts does have its schedule run every minute, but all it does is retrieve the drafts whose scheduled time has passed, publishes them, and deletes the draft.
Other extensions may have stuff configured for other intervals. The schedule:run
command takes care of that for you, alongside the extension's code. For example, fof/open-collective
has its command run every hour instead.
datitisev drafts does have its schedule run every minute
Okay, I understand what those scheduled drafts are, now. I am not a fan of it and will deactivate them again and I don't understand why something like this should be useful in a discussion forum? And in many cases, if I don't understand something, I ban it from my life... or at least from my forum.
Thanks for the good explanation and help
Are there other things Flarum does with the cronjob, except of the extensions listed above? Like time based suspension of users?
maxmoon time based suspension of users
This features does not use the scheduler, the date of suspension end is simply checked every time the user tries to perform an action.
If you are trying to list every extension that uses a scheduled command, there's at least one more, my Popular Discussion Badge extension https://discuss.flarum.org/d/24490-popular-discussion-badge but it's an optional feature.
- Edited
IanM $ crontab -e
When i did this it showed this - https://prnt.sc/TVBkjROQ9b-u
IanM * * * * * cd /path-to-your-project && php flarum schedule:run >> /dev/null 2>&1
When i did this it showed this - bash: ads: command not found
so i run this command -
IanM cd /path-to-your-project && php flarum schedule:run simply says php flarum ......
It showed this - No scheduled commands are ready to run.
IanM Do we still need to run it if we have redis and Redis sessions, cache & queues Installed?