Hi,
I had a similar problem with CAS authentication, launching moodle/auth/cas/cli/sync_users.php, exactly like in this thread.
Problem resolved using more PHP memory (512M to 1024M in my case ; memory_limit=1024M) to execute this script, as explained in this discussion
Séverin