datitisev 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.

datitisev 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

    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?

        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.

        https://prnt.sc/PsjPcu_iPnGM

          HD3D yes, the scheduler is an independent functionality to the queue. If any extensions are using the scheduler, it should be set up to run.

          6 days later

          xasharma

          If you're having trouble configuring a cronjob, you can use systemd.timer, which is a bit more straightforward, or use a looping script:

          #!/bin/bash
          while true; do
              cd <path_to_flarum_dir> && php flarum schedule:run
              sleep 60
          done

          Ideally in a container.

            Prcek Sorry I am begineer , Please guide, I am using cpnael.

              xasharma I'm sorry, but I don't use cPanel. I'm more old school Unix. CLI and all that 😄 But I'm sure the cPanel pros will get it together somehow 👷🏻‍♂️

              5 months later

              We are trying to create a php file that cron can execute. The php file contains:

              <?php
              flarum schedule:run >> /dev/null 2>&1;
              ?>

              But it does not work when trying to execute this. There is a parse error. Any help is appreciated 🙂

                cmsoc you are confusing shell commands and PHP code.

                The Flarum scheduler is only meant to be called directly from the CRON configuration. If you need to call a Flarum command from another PHP script you need to either start it as a shell subprocess or import, boot Flarum code then create and dispatch the Symfony command in application.

                If you are trying to work around some limitation by your host, please describe your situation in more details so we can understand what you are trying to do.

                  clarkwinkelmann I am using Cloudways and they support executing a Cron schedule to run a PHP file. So, I am entering the required command in a PHP file and passing that file as the input to run via Cron.

                  • ctml replied to this.

                    cmsoc

                    flarum is the php cmd you want to run, so you could point to it directly however I think when it comes to the scheduler there is a limitation where it must be executed from the directory where flarum resides which may or may not be an issue for your host.

                    So you could try pointing it directly at flarum, which is a php file itself

                    $ head flarum
                    #!/usr/bin/env php
                    <?php
                    
                    /*
                     * This file is part of Flarum.
                     *
                     * For detailed copyright and license information, please view the
                     * LICENSE file that was distributed with this source code.
                     */

                    Scheduled command: flarum schedule:run >> /dev/null 2>&1

                    But if that doesn't work, you could try the shell_exec method from your own php script.

                    https://www.php.net/manual/en/function.shell-exec.php

                    <?php
                    $output = shell_exec('cd /path/to/directory && flarum schedule:run >> /dev/null 2>&1');
                    ?>

                      ctml Thank you. Let me try and get back to you.

                      Update: It worked fine 👍

                      16 days later

                      l using Cpanel l add commands with CronJobs but not active this function.

                      l add command all version but not working 😆 Please help

                        Mirzaagha Change the command line with in the bellow and don't forget to change the main-directory and site-directory text:

                        cd /home/main-directory/site-directory && /usr/local/bin/php flarum schedule:run