Troubleshooting
Moodle warning: activity deletion in progress
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
- Go to Site administration > Server > Tasks > Ad hoc tasks.
- Find
\core_course\task\course_delete_modulesand check its failed attempts, next run and error message.tool_recyclebin\task\cleanup_course_binonly removes expired items from the recycle bin; it does not complete this pending deletion. - 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.
- Confirm that
course_delete_modulesfinishes 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. - 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
- Diagnose "Missed schedule" Check why a scheduled post was not published before replacing WP-Cron with a server task.
- "An error occurred while sending the message" in the PrestaShop contact form Diagnose the contact form rejection and fix an old override only when it does not send contactform's...
- 404 errors on static files slow down browsing Detect missing static resources that trigger PHP and use CPU, serve them as lightweight 404s and gui...
- Debug errors in WordPress Find WordPress blank screens and internal failures by sending WP_DEBUG to a private log, without sho...
Something wrong or out of date? Tell us and we will review it.