Cron stopped because "time limit has been reached"

Cron stopped because "time limit has been reached"

by Luis de Vasconcelos -
Number of replies: 1
Picture of Particularly helpful Moodlers

I was checking the cron logs on my Moodle 3.9.13+ site and I came across the messages below saying that the cron processing was stopped because the "time limit has been reached" :

Execute scheduled task: Remove unused random questions (qtype_random\task\remove_unused_questions)
... started 01:20:33. Current memory use 21.5MB.
Cleaned up 10000 unused random questions.
... used 646370 dbqueries
... used 3337.20012784 seconds
Scheduled task complete: Remove unused random questions (qtype_random\task\remove_unused_questions)
Stopping processing of scheduled tasks as time limit has been reached.
Stopping processing of adhoc tasks as time limit has been reached.
Ran 0 adhoc tasks found at Wed, 13 Jul 2022 01:20:01 +0200
Cron script completed correctly
Cron completed at 02:16:10. Memory used 25.4MB.
Execution took 3369.693501 seconds

What time limits is this referring to? And where do I check what those time limits are?

And 3369.693501 seconds = approximately 56 minutes. Is it normal for for a cron script to run for so long?

Average of ratings: -
In reply to Luis de Vasconcelos

Re: Cron stopped because "time limit has been reached"

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

What time limits is this referring to? And where do I check what those time limits are?

Presumably those on Site administration ▸ Server ▸ Tasks ▸ Task processing:

Screenshot showing settings task_scheduled_max_runtime: 30 minutes; task_adhoc_max_runtime: 30 minutes

And 3369.693501 seconds = approximately 56 minutes. Is it normal for for a cron script to run for so long?

Yes but qtype_random\task\remove_unused_questions is a workaround for the very large number of mdl_question rows that random questions can result in (MDL-64595) so that specific task can take a long time especially if it's the first time it has been run.

Average of ratings: Useful (2)