- No suggested jump to results
- Notifications
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account

Task usersync returned a "cannot optain task lock" #1132
RSickenberg commented Aug 12, 2019 • edited
mmulrthelp commented Aug 12, 2019
Sorry, something went wrong.
RSickenberg commented Aug 12, 2019
- 👍 1 reaction
jamesmcq commented Aug 13, 2019
Mmulrthelp commented aug 13, 2019.
No branches or pull requests

Documentation
- Scheduled tasks
- System paths
- Session handling
- Maintenance mode
- Environment
- Site registration
- Mail configuration
- OAuth 2 services
- 1 Managing scheduled tasks
- 2 Format for scheduling tasks
- 3 Fail delay
- 4 Running individual tasks
- 5 Tasks running now
- 6 Launching a task from CLI
Managing scheduled tasks
An administrator can schedule routine tasks very precisely from Administration > Site administration > Server > Tasks > Scheduled tasks.
Note that you still need to run the cron scripts (admin/cli/cron.php or https://yoursite/admin/cron.php ) at regular intervals. It is recommended that the cron is run every minute.
Clicking the edit icon allows the administrator to specify the minute/hour/day/month or day of the week the task is to be run. It is also possible to reset the task to its default setting or disable it completely.
The column 'Next run' provides information on whether a plugin or a task is disabled (as well as the date that a task will next run).
Format for scheduling tasks
When typing into the fields, the format is the same as for Unix cron. Examples are as follows and are according to which field you are editing:
Default: R means that a random value is picked when saving changes. This helps to distribute tasks more equally instead of running too many of them on the hour, midnight etc.
If you're trying to debug a cron task, you may notice the Fail Delay becomes populated with a number. This is the time in seconds the cron will delay running the task. To sidestep this problem for development purposes, take a look at the Scheduled Tasks section here: Administration_via_command_line#Scheduled_tasks .
Running individual tasks
To be able to run individual scheduled tasks via 'Run now' links on the scheduled tasks page, 'Allow 'Run now' for scheduled tasks' (tool_task | enablerunnow) in Site administration / Security / Site security settings should be enabled AND 'Path to PHP CLI' (pathtophp) in Site administration / Server / System paths should be set.

Tasks running now
Currently running tasks may be viewed from Site administration > Server > Tasks >Tasks running now

Launching a task from CLI
You can also launch individual task from Command Line Interface (see Administration via command line ).
- Site administration


IMAGES
VIDEO
COMMENTS
Re: Cannot obtain task lock - qtype_random\task\remove_unused_questions) by Christophe BOITEUX - Wednesday, 11 September 2019, 8:16 PM. For me, to unblock (cron.php) the situation on the serveur : ps aux | grep php for obtain the list of processes. a = show processes for all users. u = display the process's user/owner.
'Execute scheduled task: Sync users with Azure AD. (local_o365\task\usersync) Cannot obtain task lock' Previously we've managed to get around this by rebooting the server, but that was when we encountered it on our DEV site. This is no longer a viable option. We are running Moodle 3.6.3 with local_o365 version 3.6.0.0 : 2018120300
It is also possible to reset the task to its default setting or disable it completely. The column 'Next run' provides information on whether a plugin or a task is disabled (as well as the date that a task will next run). Format for scheduling tasks. When typing into the fields, the format is the same as for Unix cron.
Cannot obtain task lock. I'm running 3.5.2. Cron is running every minute and other tasks are fine except LDAP sync users this one. If i click 'run now' in scheduled tasks, it works fine. But when i manually run the php script it gives me error: cannot obtain task lock. I guess this is the reason why it doesn't run it as scheduled but cannot ...
Hi all, I am trying to create a custom scheduled task to automate creating categories from an 'external' database. I have created the table I need (its actually an additional table within the moodle database for now, but the code that reads it might get changed to point to a completely external one - but for now that's not the issue, that bit works on my dev environment).