There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Bill Hopkinson -
Number of replies: 10

Moodle 3-10, installed on my own VPS using a one-click facility provided by my server host Fasthosts. database MySql.

I am still building my courses, and as an experiment tried to create a copy of my first unfinished course. Following this I get the warning There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

I deleted the copy, but still get the message.

I checked in Courses - Backup that asynchronous backup is disabled.

So, is the message false, and how do I get rid of it? Is there somewhere I can edit cron to remove the action, for example? Not accomplished with php but I can follow explicit instructions


Average of ratings: -
In reply to Bill Hopkinson

Re: There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Copying a course in Moodle works by creating a backup of the course, then restoring this as the new course. The backup/restore operation depends on the Moodle cron running. Has this been set up? If not there'll be a warning on Site administration ▸ Notifications about this.

Without the cron running you should be able to get rid of the There is a pending asynchronous backup… message by editing the database. First back up the database before making changes, then run the SQL statement:

DELETE FROM mdl_backup_controllers WHERE purpose = 80;

assuming $CFG->prefix is 'mdl_' for your site.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Bill Hopkinson -
Cron is running on my VPS, I can see a whole load of executions, but yes, the issue is, in Site Administration notifications - The admin/cli/cron.php script has never been run and should run every 1 min.
So, how do I set up cron.php to run? Bear in mind I have never had to set cron to run
In reply to Bill Hopkinson

Re: There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The exact steps needed to set up cron will vary with the VPS operating system and whether you're using the command line or a web interface to manage this. There's documentation here. For my CentOS 8 server with Moodle in /var/www/moodle and PHP being run as user apache I would edit that user's crontab (the list of cron entries) with:

# crontab -u apache -e

and add a line to run the Moodle cron script every minute:

* * * * * /usr/bin/php /var/www/moodle/admin/cli/cron.php

Ensuring cron is running is essential for Moodle to work properly. If you get stuck please reply including details such as the VPS's operating system, what you've tried and any results.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Bill Hopkinson -
I have not used anything previously to manage cron. I need to learn how.
VPS OS is Ubuntu 20.04.2 with Apache, but I use Plesk Obsidian to operate things, and although that has several Cron operations running. it does not appear to have anything which makes it easy to run a new cron script. Moodle cron did not start automatically on installation.
My cron file is located on https://mydomain.com/moodle/admin/cli/cron.php

So, I find the command line, not used before, and type /usr/bin/php /var/www/moodle/admin/cli/cron.php? Do I not direct it to my domain?
In reply to Bill Hopkinson

Re: There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Bill Hopkinson -
I tried command line and got "run with error"
Then I used Plesk to create a scheduled task on my domain for /moodle/admin/cli/cron.php? and that returned Task "/moodle/admin/cli/cron.php" completed with error in 0 seconds. See details - but details were empty.
Is there anything wrong with my cron.php?
In reply to Bill Hopkinson

Re: There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Both the server's scheduled task system and Moodle's scheduled task script are called cron which is confusing. So I'm going to say server cron for the former and Moodle cron script for the latter.

Do I not direct it to my domain? – We need to get the server cron to use PHP to run the Moodle cron script which is located in a folder on your server. I don't know where the one-click installer installs that to, hopefully you can determine the location for this.

Is there anything wrong with my cron.php? – That's the correct file for Moodle 3.10.

You need to ensure the command the server cron runs starts with the path to PHP (/PHP_PATH/php /MOODLE_PATH/moodle/admin/cli/cron.php). The path to PHP is typically /usr/bin/php but might be different location on your server. If you do have command line access then the command which php should show where this is located.

If it's still not working can you share a screenshot of how you've configured this in Plesk? Obscure anything you don't want to share on the Internet.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Bill Hopkinson -
Thanks for the help.
I managed to run cron successfully as a one off without schedule, and remove the asynchronous backup notice.
One more piece of advice needed, as, when I run cron setup on Plesk it does not give me an every minute option, only hourly to yearly, or UNIX crontab format. Would I be right in thinking that ***** would be UNIX crontab format for every minute?
Attachment cron.jpg
In reply to Bill Hopkinson

Re: There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

In Script path I'd expect this to start with a '/' to form a full path to cron.php. So if httpdocs was in /opt then this would be /opt/httpdocs/moodle/admin/cli/cron.php.

Yes, * * * * * means every minute. From the manual page:

       The time and date fields are: 
 
              field          allowed values
              -----          --------------
              minute         0-59
              hour           0-23
              day of month   1-31
              month          1-12 (or names, see below)
              day of week    0-7 (0 or 7 is Sunday, or use names)
 
       A   field  may  contain  an  asterisk  (*),  which  always  stands  for
       "first-last".

(Moodle also uses this notation).

If you select "Cron style" in Run that can you type * * * * * in the box on the right?

In reply to Bill Hopkinson

Re: There is a pending asynchronous backup for this course. Please do not edit this course until backup is complete.

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
'/usr/bin/php /var/www/moodle/admin/cli/cron.php' is the right thing. But you should see the output. Example:
Execute scheduled task: Hintergrundprozess für Mitteilungen (core\task\messaging_cleanup_task)
... started 13:44:18. Current memory use 18.9MB.
... used 5 dbqueries
... used 0.013534069061279 seconds
[many similar messages]
Cron script completed correctly
Cron completed at 13:44:19. Memory used 37.8MB.
Execution took 1.378231 seconds

Ideally the script should run by the same user as the owner of the web server process. For details, see https://docs.moodle.org/310/en/Cron.