Course copying in progress - STUCK

Course copying in progress - STUCK

by Juno Sprite -
Number of replies: 18

Hi there, Moodle community.

Preliminary considerations:

  • I'm using Moodle 3.9, cloned from GitHub, using version control.
  • No apparent error messages (not sure where they would be saved).
  • Running CentOS 7, with full root access to server via SSH, FTP, and cPanel/WHM access.
  • Using Apache 2.4, MariaDB 10.3, PHP 7.2 (though, I've unsuccessfully tried to switch to PHP 7.3).
  • After 24 hours of course copy being apparently stuck, I deleted the following moodledata subfolders, in a frantic attempt to fix the issue:
  1. cache
  2. localcache
  3. sessions
  4. temp
  5. trashdir

Persisting issue:

After using the "Copy course" feature on the Moodle course settings, I have found that anytime I try to copy a course, it never finishes. In addition, that prevents me from attempting to copy the same course again. I have since found that creating a new course, then importing data from the desired course, is a decent workaround to this issue. Unfortunately I now have two courses that are stuck in this Course copying in progress limbo. Developer mode was on at the start of the second failed course copy and produced no errors.

Followup questions:

  1. Where would errors for this type of stalling issue be sent to?
  2. Why is this happening? Does it have to do with memory allocation? Should I change some function timeout setting or something?
  3. How can I remove these copies that are "in progress", so that they no longer appear for me or other site administrators?
Average of ratings: -
In reply to Juno Sprite

Re: Course copying in progress - STUCK

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
In reply to Visvanath Ratnaweera

Re: Course copying in progress - STUCK

by Juno Sprite -
It might be related, but I do believe this issue began before my PHP scripts stopped working. I'll check back in after fixing cron issues to report if that solves this issue as well.
In reply to Juno Sprite

Re: Course copying in progress - STUCK

by Aki Tsirigotis -

Has anyone resolved this? I am having the same issues with mine.

In reply to Juno Sprite

Re: Course copying in progress - STUCK

by Brendon Hatcher -
Try this....
Site administration / Courses / Backup
Disable asynchronous backups
Average of ratings: Useful (1)
In reply to Brendon Hatcher

Re: Course copying in progress - STUCK

by Aki Tsirigotis -
Unfortunately, this did not resolve the problem. I also ran a manual cron job and nothing. It is showing all of my course copies as pending back up scheduled for the 27th of September.
In reply to Aki Tsirigotis

Re: Course copying in progress - STUCK

by Simon Quutznär -


Well, I have the same problem!

Backup
Process pending for over 24 hours ...

In reply to Juno Sprite

Re: Course copying in progress - STUCK

by qwe qwe -

Same.

Asynchronous backups are not enabled.

Moodle 3.9.1

Average of ratings: Useful (1)
In reply to Juno Sprite

Re: Course copying in progress - STUCK

by Patrick Felipe -

Assim que ativei Backup/restauração assíncrona, foi na pasta do moodle e executei:

"php admin/cli/cron.php" 

E a copia funcionou.



Average of ratings: Useful (1)
In reply to Patrick Felipe

Re: Course copying in progress - STUCK

by Juno Sprite -
Hello all! I'm sure glad I brought attention to this to see that I am not the only one struggling with this issue. It's brought me so much anxiety that I just let it be for now, meaning I have not yet solved this issue. I've also been way too busy with other things.

@Patrick, I'm not very good at my Portuguese or Spanish or whatever language you're speaking, but I think I understand enough. I have run "php admin/cli/cron.php" in the command line dozens of times to no avail. I will be migrating over to AWS in the summer and doing a fresh Moodle install, so I'm hoping that will magically resolve my issues with cron.php.

To everyone: I will respond if I figure out this issue. I hope you all would, too. I share your frustrations.
In reply to Patrick Felipe

Re: Course copying in progress - STUCK

by Jose User -

Thank you @ Patric, this worked for me.

Google Translation smile
As soon as I activated asynchronous Backup / restore,  from Site administration / Courses / Backup 

and executed the command below 

 php admin/cli/cron.php

it worked.

For me, I executed the command from the moodle folder, where I have it installed.

  /home/[usernamename]/[websitename.com]/moodle

Since there are some known issues with older php version, I checked my php version to make sure it was 7.0 or higher. My server had multiple Php versions, so I also made sure that was addressed before running the command, 

cd ~

 export PATH=/usr/local/php74/bin:$PATH

then executed the php command above as indicated by @Patric




Average of ratings: Useful (2)
In reply to Jose User

Re: Course copying in progress - STUCK

by Mike North -
The following worked for me, hopefully it will help others, specifically those who use Siteground (which no longer uses cPanel).

I didn't enable asynchronous backup (not sure if I need to or not, but my courses finished copying once I did the below so for the time being I haven't enabled this option).

This is the command that I used:

/usr/bin/php /home/a111-okjulkji65rr/www/mywebsite.com/public_html/moodlesite/admin/cli/cron.php >/dev/null


Don't copy and paste the above command! Instead create a new one and fill it with information specific to your website.

How to create your own command and each portion of the above code is explained below:

1.   /usr/bin/php

This is the location of where php can be found on Siteground. For siteground you do not need to put the specific php version, unless you have installed multiple versions and want to point to a specific version. If you're not sure where your webhost keeps the latest php version then contact them to find out, otherwise try the above.

There is a space between this and the next portion, that's not a mistake.


2.   /home/a111-okjulkji65rr/www/iloveapples.com/public_html/moodlesite/admin/cli/cron.php >/dev/null

This is the command that we want executed in the background on our website. It's basically saying "look in this location of my website, find the file named cron.php and execute it".

Now to explain each component within this string so you can create your own command.

2.1   /home
Leave this as it is, it just says to start looking in the home folder on your website.

2.2   /a111-okjulkji65rr
This is apparently my username on Siteground, although I'd never seen it before and is not the same as my login username.
(Please note the one shown above is not my real username, it is a fake one I'm using in this example for security reasons but looks similar to my real one and if you use Siteground then yours will look similar.).

To find your username either contact your website or if you use Siteground to host your website then go to:
Site Tools  >  Devs  >  SSH Keys Manager

Now maximise your browser so you can see a grey box halfway down the page on the right hand side titled SSH CREDENTIALS and it will show your username there. If you can't find it then contact your webhost (I couldn't see it at first as my browser screen was not maximised and Siteground completely removes this grey box unless the browser window is stretched wide.... thanks Siteground!).

2.3   /www/iloveapples.com

This is where you enter your website URL. (This is not my actual website, just using a fake one for this example.)
The forward slash after www is not a mistake (don't use a period . )

So if your website is:


then convert this to:

/www/artsandcraftsinmichigan.com

2.4 /public_html/moodlesite/admin

This is the specific folder where the file named cron.php can be found on my website, but it will be a bit different for you. The main difference will probably be what folder your moodle website is located in. Mine is located in a folder called "moodlesite" so find your folder name and use that instead, but the "public_html" and "admin" portion will most likely be the same as in the example above.

If you're not sure then search your website and look for the file named cron.php then type in the path where it can be found. Again, contact your webhost if you're not sure what to put here.

2.5   /cron.php

As mentioned above, this is the actual file that we want our website to execute in the background so no need to change this.

There is a space between this and the next portion, that's not a mistake.


3.   >/dev/null

You don't have to enter this, but it basically says "don't send me notification emails every time this command is executed". If you leave it out then you will receive a notification email every time the command is executed. 

I would recommend initially to not include this so you can see if the command is actually working or not, then once you can see it's working add it to your command. Others have mentioned you can see the status of your command within Moodle but I haven't figured out how to do that yet.


Ok so those are all the necessary components. Now using the info above create your own command. Maybe type it up in Microsoft Word / Notepad etc. so you can easily copy and paste it.

If using Siteground then next we need to create a "Cron Job" which is basically an instruction to tell your website to run the above command.

If you're using Siteground then do the following:
  1. Go to:
    Site Tools  >  DEVS  >  Cron Jobs

  2. In the field titled "Command" enter the command you've created

  3. In the field titled "Interval" select "Twice per hour" or select "Manual" and type one of the following:

    * * * * *             (this runs the command every minute, see below)

    0,30 * * * *        (this runs the command every 30 minutes, see below)

    Now regarding the interval duration, Moodle recommends setting this to run the command once per minute but Siteground gave me the following advice:

    "I have noticed that your cron job is set to execute every minute, please note that this setup will generate excess CPU seconds usage on your account due to which it may reach its CPU seconds usage quota and be limited, hence I will strongly recommend setting up this cron job, and future ones, to be executed once every 30 minutes."

    I haven't got a clue what any of that means so I've set it to 30 minutes! Can anyone advise?

  4. Once you've created your command then click on "Manage Notification Emails" and type in the email address you'd like to use. Keep in mind if you've chosen to run the command once per minute then you'll be inundated with emails.

    Check your email and see if you've received an email from "Cron Daemon" (this might be specific to Siteground) and if the email is a long list of executed tasks then your command is working. If you receive an error message in your email instead, e.g. "Could not open input file" then there is a problem with your command line, specifically the path leading to cron.php and you should contact your webhost for advice.

  5. If you want to stop receiving constant emails then edit your command to include >/dev/null at the end, which basically says "stop sending notification emails"


Ok hopefully someone finds the above useful. I have been struggling with this the past few days and figured there might be a few others out there who might benefit from some of the above.

Average of ratings: Useful (1)
In reply to Mike North

Re: Course copying in progress - STUCK

by Sarra Lev -
Sorry, for someone who has no idea what it means to execute a command, can you explain how to do this on MoodleCloud step by step? Thanks. I'm having so much trouble with Moodle these days sad
In reply to Sarra Lev

Re: Course copying in progress - STUCK

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Hello Sarra. I don't think you can execute commands on MoodleCloud but if you are having trouble with copying a course on MoodleCloud then I suggest you contact them via your MoodleCloud portal.
In reply to Juno Sprite

Re: Course copying in progress - STUCK

by Ken Task -
Picture of Particularly helpful Moodlers

Don't have the issue ... so these are suggestions ... things to check/look at:

When one copies a course first thing it does is make a backup of the course being copied.

Check moodledata/temp/backup/ for contenthash named directories.

Contained therein, if backup was successful, a moodle_backup.xml file will be present as well as a backup file called 'backup.mbz' (which hasn't been copied yet).

If still in progress, might be a failed backup.  Large course?
Can you backup that course to be copied using normal GUI backup?   How about backing up that course from CLI using admin/cli/backup.php using a specified directory to save to?

Set the path to php-cli on your system (system paths in Moodle Admin)
then go to Scheduled Task.  Those task are part of the overall cron.

If you set the php-cli path there is a run now link.   On anything related to
courses, click run now.

There is also in /admin/tool/task/cli/ a adhoc_task.php script which is supposed to find cron jobs not yet completed and will attempt to complete them.

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Course copying in progress - STUCK

by Carlos Melero -
I have had this issue and I have fixed it.

I executed the CRON job from console and I saw that "reminders" plugin was causing an error. I disabled the plugin and executed the cron process again.

That was all...

I hope this will help someone.
Average of ratings: Useful (2)
In reply to Juno Sprite

Re: Course copying in progress - STUCK

by Emil Mandyczewsky -
I have the same issue which seems to have occurred recently. Before that I was able to copy courses no problems.

For clearing the copy progress, see my reply in thread here - https://moodle.org/mod/forum/discuss.php?d=425021#p1711698

As for why it happens, I have tried all that I can find here - cron active, asynchronous backups on or off etc. I am getting a third party vendor to investigate my debugging logs and will post the results here.