Hi there,

I have a members-only site where anonymous users have absolutely no access to anything. In this situation, I can't get cron to run automatically via a system cron job. One route, of course, is to use wget cookie handling to login and run cron via a script, but I before I waded into those waters, I wondered whether there was a short cut people knew about.



carnevaledesign’s picture

Is CURL installed on the server? If so, you could set the command to "curl http://www.yoursite.com/cron.php"

Anonymous’s picture

Sounds like it's the same idea - use cURL to store the cookie and login.... I guess perhaps that's the best bet, anyway.

Anonymous’s picture

Here's the script that runs cron using wget on a site with no access for anonymous users. Requirement: create a new user for cron. I thought about creating a role that just allowed the cron user to see some content, and test it, but I ended up making this a regular authenticated user, and made the script readable only by root. I probably would not do this on a shared server, if your content is sensitive.




wget -O /dev/null --save-cookies /tmp/site-cookies.txt --keep-session-cookies --load-cookies $cookies "${site}user"
wget --keep-session-cookies --save-cookies $cookies --load-cookies $cookies -O /dev/null --post-data="name=$name&pass=$pass&op=Log%20in&form_id=user_login" "${site}user"
wget --keep-session-cookies --save-cookies $cookies --load-cookies $cookies "${site}cron.php"

webpotato’s picture


I added a node that contains a php script that detects if the user is authenticated or not and redirects anonymous users to another node. Cron was working before this page went up. I had cron running from crontab every hour and working fine. After I put the node with the php redirect up, cron fails and I get the html from the page anonymous users are redirected to as an error message. I'm using Drupal 6.

I think having a "cron user" would solve my problem. I tried your cookie recipe (yes, adding a new user account first, etc.) but I get "Invalid Null Command". I don't know much about wget, so I'm unclear what dev/null is. Any suggestions for making this work? I am on a shared server for now, but no sensitive info.

You had mentioned an alternative method that you abandoned: "creating a role that just allowed the cron user to see some content..." What might that method involve? Does Drupal have a setting for a "cron user" somewhere? I'm missing something but I need crontab to work.