a month later

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!

7 days later
a month later

hello. Please explain how to setup corn in cPanel. I'm try 100 times, but it's not work.

    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.

    11 days later

    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:

    Image

    Image

    And even users can activate a cron without any problems/errors (without the cronjob above):

    Image

      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.

        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 👷🏻‍♂️