Troubleshooting

Moodle warning: activity deletion in progress

Reviewed on 3 min read cron errors

If you try to restore a deleted activity in Moodle and this message appears:

Warning: Activity deletion in progress! Some grades are about to be deleted.

The message means Moodle still has a deletion pending. Before blaming the general cron, check the ad hoc task that processes that deletion and its exact error.

How to fix it

  1. Go to Site administration > Server > Tasks > Ad hoc tasks.
  2. Find \core_course\task\course_delete_modules and check its failed attempts, next run and error message. tool_recyclebin\task\cleanup_course_bin only removes expired items from the recycle bin; it does not complete this pending deletion.
  3. Run the cron from the CLI and keep the output during diagnosis:
/opt/alt/php83/usr/bin/php /ruta/a/moodle/admin/cli/cron.php

Replace php83 with your Moodle's PHP version: a plain php or /usr/local/bin/php may be a different version. You will find all the paths in PHP binary paths.

  1. Confirm that course_delete_modules finishes correctly. If it fails, fix the specific error of that run first; running the cron over and over does not repair permissions, disk space or plugin exceptions.
  2. Check that the course recycle bin is enabled and that the retention period has not expired. Only after the task completes should the recoverable item appear.

Schedule the cron

Moodle recommends running it every minute. During diagnosis you can temporarily set up a cron job with the real path and save the output:

* * * * * /opt/alt/php83/usr/bin/php /home/usuario_cpanel/public_html/moodle/admin/cli/cron.php >> /home/usuario_cpanel/logs/moodle-cron.log 2>&1

Check the log until you have confirmed several successful runs. Then, if you already have another way to review task failures, you can remove that redirection so output does not pile up on disk:

* * * * * /opt/alt/php83/usr/bin/php /home/usuario_cpanel/public_html/moodle/admin/cli/cron.php > /dev/null 2>&1

Delete moodle-cron.log when you no longer need it. Running /admin/cron.php from the web depends on Moodle allowing it; the CLI is the recommended method.

See the official guide to Moodle cron and its scheduled and ad hoc tasks.

Before adding another cron job

Check whether an equivalent task already exists for the same installation; fix that entry instead of duplicating it. Use the PHP binary compatible with your Moodle version and the user that owns its files. Create the private log directory beforehand and limit its access and retention.

Sending the output to /dev/null also hides the process errors: keep reviewing failed tasks in Moodle. Do not manually delete task, activity or grade rows to get rid of the warning. Once the deletion finishes, there is no guarantee you can restore an item if the recycle bin was disabled or its copy no longer exists.

You may also find useful

Something wrong or out of date? Tell us and we will review it.