I have been trying for a couple of days to get cron to work properly. I have tried 3 different ways of triggering cron.
1 If I am logged in to my site then I can access cron via a browser and cron then works properly. Watchdog records "Cron run completed".
2 On the other hand if I am not logged in, cron does not work, when cron.php is called via a browser. In that case, Administer -> Settings -> Cron jobs says "Cron is running. The last cron job ran xx sec ago" Where xx is the time since I tried using the browser. However cron based actions are not run and watchdog does not say "Cron run completed".
3 If I run cron from cpanel, the result is as in Case 2 above.
I have tried disabling modules to see if one is stopping cron but this does not appear to have any effect.
I suspect that I have a file permission or .htaccess set wrongly but I can not figure it out. Suggestions would be much appreciated
Comments
Did you remove the Anonymous
Did you remove the Anonymous user? I had a similar experience when I removed user 0 from the users table in the DB.
Re-adding a user 0 seemed to correct the problem.
The reason it works when you use your web browser is that your user is probably still authenticated (session still active).
Anonymous user
Sadly that does not appear to be the problem
Thanks for the try
Try poormanscron
it might resolve your problem.
Poormanscron problems now.
Thanks for the suggestion. I am using cron jobs with simplenews to send out emails to about 450 members. My hosting company (Bluehost) will only allow 50 outgoing emails per hour.
Poormanscron is working but it occasionally triggers off several times close together, despite being told to trigger only every 15 minutes. When that happens the limit of 50 is exceeded and mail is rejected.
Regretably I still need help. I still feel that the normal cron system should work. In case it was a problem related to file permissions, I have relaxed these down to 777 but it still only triggers if I call cron.php from a browser when I am logged in.
Do any other messages from
Do any other messages from anonymous appear in your access log?
Do any other messages
No there are no messages from ananymous in the log.
I am still struggling with cron. Since my last comment, I have done the following.
1. Set up drupal 4.7 on a test site. All worked OK including cron.
2. Copied my main database onto the test site. All worked OK with the exception of cron, which behaved as described in my first query.
3. Severely restricted the test site by disabling all modules eg forum, book, taxonomy, simplenews, menu etc that were not vital. cron still did not work.
It appears that something in my database is stopping cron from working
Hmm. I would try this
Hmm. I would try this next:
1. Reset your dev site. Log in, make sure that it works, and make sure cron works.
2. Export your prod DB to an SQL text file
3. Find the statements around the 'users' table in the SQL dump. Remove the "drop table users" line.
4. Run the sql against your dev db. The users table should generate at LEAST 1 error (user 1 already exists).
5. Try cron again.
By the sounds of it, it sounds like user 0 is missing from your users table.
Eureka !!
Many thanks Timatlee; that was the problem. I shortcircuited your instructions a bit (you were probably being cautious not knowing how competent or otherwise I am.) I used phpMyAdmin to confirm that there was no user 0 on my test site. I then followed the advice given in http://devbee.co/all_important_user_zero to insert a user zero - cron started working straight away.
I repeated the same process on my live site and all was fiine as soon as I had tidied up the permissions (including taxonomy access settings) for the anonymous user.
I am most grateful for your assistance. My tests had shown that the problem was related to the database, but it would have been a very very long time before I had tracked the problem down to user 0. The only thing that puzzles me now is how I lost user 0 in the first place.
Hey Jimjim ... glad it
Hey Jimjim ... glad it worked!
I never know how familiar someone is with PHP and MySQL, or what tools they're using, so I try to simplify instructions a bit...
The same thing had happened to me a while ago.. cron and other anon messages stopped working. EIther it was a bad import script (converting from a Geeklog website), or I was digging around the users table, and wondered why there was an empty record - and decided to clean it up. Either way subsequent sites haven't been a problem now that I know user 0 is "off limits".