I have configured the LDAP authentication and added /auth/ldap/cli/sync_users.php to the crontab as described in the official manual: http://docs.moodle.org/26/en/LDAP_authentication.
But with no luck the LDAP thingy seemed to be failing to work properly. I believe the cron job has been set up properly, so I suppose I may have made some mistakes, or not providing enough information in the configuration for the LDAP authentication plugin.
As the cron script must be called from the command line, and I only have access to the FTP and MySQL database on the server, I have no idea how to execute the file to check if there are any errors (for debugging purpose).
So, I would like to know the proper way(s) to debug the LDAP authentication.
Please let me know if I am not making it clear enough. I could provide more details if needed.
Thank you.
UPDATES * * * *
I have tried to run the /admin/cron.php on a browser, and I have found the following lines in the output.
Running auth crons if required...
... started 10:24:18. Current memory use 27.9MB.
Does it have anything to do with the LDAP authentication? And what does it imply here?
Have you got something like this in your cron?
*/15 * * * * /usr/bin/php /path/to/moodle/auth/ldap/cli/sync_users.php >/dev/null
You could probably redirect the output to a log file to see whats going on.
*/15 * * * * /usr/bin/php /path/to/moodle/auth/ldap/cli/sync_users.php > /path/to/home/ldaperrors.log 2>&1
Also try it with debugging - add these to the config.php - not on a production site though, otherwise your users might see lots of errors.
#error_reporting(E_ALL | E_STRICT);
#ini_set('display_errors', '1');
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;
For those who stumble upon this via a search...
In Moodle 3.0 and above, cron jobs can be viewed and run from Site Administration>Server>Scheduled Tasks.
Very useful to view output of the task (in this case the LDAP authentication).
Related
I cant get the Cron Job set up on our server to send out password resets and email confirmations. Have I set it up correctly? Have tried many different ways - the latest being:
curl -L -s http://www.****.com/cron.php
*/5 * * * *
Is this right? Ideally I'd like to set it to instant for now so I can see if is working, then change to every 5 minutes.
Update: I've been told by our server provider it has been set up properly, so is there anything within Magento I should check?
Thanks.
I'm trying to set up a CRON job for my laravel 4.2 app and am strugglng to get things to work.
I've created a command which works successfully from the command line. I first tried created a CRON task with my service provider but was unable to get this to work. I tried:
/usr/bin/php /var/www/vhosts/mydomin.co.uk/subdomains/golfmanager/httpdocs/artisan reminder:week
This does not appear to work
I then tried:
/usr/bin/lynx -dump /var/www/vhosts/mydomain.co.uk/subdomains/golfmanager/httpdocs/artisan reminder:week
That failed to work either. My understanding is Lynx is a browser? but I assume because all the traffic is re-routed this approach won't work for a Laravel app?
So I then installed the package [liebig/cron][1] with a view to getting that up and running. I created a cron task with an external provider 'cronservice' which appears to be triggering but I'm not getting the expected results from the task.
I have configured the package as described and have current placed the following in bootstratp/start.php
Event::listen('cron.collectJobs', function() {
Cron::add('reminder-week', '*/15 * * * *', function() {
echo "Running Task";
Artisan::call('reminder:week');
return true;
});
});
The package logs activity to a database. I can see a log entry suggesting it's fired but can't see an entry that the job has worked. Laravel log files suggest there is an httpfoundexception
I've not created a route for CRON - the readme suggests it's using an internal one?
I'm quite confused. I'd like to stick with the package approach and the external provider but not sure if I now need to create a route and how I can test the set up is correct and the jobs will work.
I've tried running the script from the browser `http://mydomain.com/cron.php?key=xxxxx' but that also throws an httpnotfound exception
ANy help appreciated to get this to work
I changed the Event::listen code to app/start/glopal.php and all working now.
Re-read the readme more carefully!
I have problems setting up a cron using CodeIgniter. I've followed the documentation and set up a test cron
* * * * * php /home/USERN/public_html/spider/index.php tools message
But this doesn't work. The output is just the index.php default controller, and not tools/message. When I run it in the terminal on the server, I get the results that I expect. Is there something I am doing wrong, or do I need to change something on the server?
For cPanel servers, in order to for CI to use the URI segments right, You'll have to use
/usr/local/bin/php
I've been searching for a while and think I have part of the information I need but just need some assistance putting it all together.
What I'm trying to achieve is to call a URL (a codeigniter controller) on a regular basis e.g. every 5 minutes which will go through my database mail queue and send the mail using amazon SES.
So far I have successfully created the controller, model, DB and SES is working just fine. The controller sends 10 emails at a time and it all works fine when I manually hit the URL.
I'm not too familiar with cron jobs, but think this is where I need to head.
My application is set up on Elastic beanstalk on AWS.
I think that I need a folder called .ebextensions in my web root, with a file called something.config in it, where I can put some 'container commands'. I also think I will need to include 'leader_only: true' in there somewhere to avoid my replicated instances doing the same jobs.
When I don't understand is what should my container command be, considering controller is 'http://myapplication/process_mail' ? From examples I've seen I couldn't see how it determines the frequency, or even the code that 'calls' the URL.
In my controller, I previously had the following code to ensure it could only be called from the command line. Is this something I can keep and have or will the container command just hit the URL like any other user?
if (!$this->input->is_cli_request()) {
echo "Access Denied";
return;
}
Thanks in advance for any help at all. I think i just need help with what should go in the config file, but then again I may have gone down completely the wrong path altogether!
UPDATE:
So far I've got as far as this:
I believe i need to run the application from the commandline like this http://ellislab.com/codeigniter/user-guide/general/cli.html
so my command would be php index.php process_mail
So what I actually need is help with running this command evey 5 minutes. This is what I have so far:
container_commands:
send_mail:
command: php index.php process_mail
leader_only: true
But what I don't understand is how I get this to run every 5 minutes, rather than just when the instance is set up. Do I need to create a cron job file on instance creation, with the php command in it instead?
Update 2:
To anyone else with the same problem, i got this sorted in the end like this:
an ebextensions file that looks like this: (.ebextensions/mail_queue.config)
container_commands:
01_send_mail:
command: "cat .ebextensions/process_mail.txt > /etc/cron.d/process_mail && chmod 644 /etc/cron.d/process_mail"
leader_only: true
a file called process_mail.txt in the same folder that looks like this:
# The newline at the end of this file is extremely important. Cron won't run without it.
*/5 * * * * root /usr/bin/php /var/app/current/index.php process_mail > /dev/null
So, every 5 minutes it runs via the cmd line the codeigniter main index file, passing in the controller name.
thanks to this: https://stackoverflow.com/a/15233848/2604392
I would set up the cron job to talk to the url, then store result in a MySQL database. Then regular PHP or any other app can connect to MySQL and access the data. That's the suggested way to connect to Twitter since a few months, so you can find info on how to do this floowing search for Twitter connectivity.
Hope this helps
By the way, while writing an email generating PHP script, I noticed that I have to slow down the pace of email sending to avoid being flagged as spammer. I added a delay of 2 seconds between emails and it did the job. My database was only 2500 so no big deal (except taking care of changing the PHP_MAXEXECUTION time variable)...
I have an MVC architecture and since I already have an action that would be extra useful if automatically called every hour or so, I wondered if there's a way to set it up as a cron job?
Don't know how periodic web page request is related to mvc, but you can achieve this by adding following line to crontab (1 hour period):
0 0/1 * * * wget <web_page_url>
Which is translated to: use wget command to request <web_page_url> every hour at zero minutes.
You can use
curl http://example.com
Or if the language you're using has a CLI client like PHP you could just run the script like
php /var/www/example.com/index.php
Edit:
For an MCV app it's probably easiest to use curl