Joaquin Posted July 24, 2008 Share Posted July 24, 2008 Hello all, I installed Drupal on one of our sites so that I could use its RSS aggregator to pull RSS feeds. Drupal requires a cron job to be setup to run cron.php in order to grab new RSS feeds regularly. I created the cron job to run every 15 minutes, and this part is working as I am getting an email about it every 15 minutes, however the email contains this error: /home/username/public_html/news/cron.php: line 1: ?php: No such file or directory /home/username/public_html/news/cron.php: line 3: include_once: command not found /home/username/public_html/news/cron.php: line 4: syntax error near unexpected token `DRUPAL_BOOTSTRAP_FULL' /home/username/public_html/news/cron.php: line 4: `drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);' "username" has been substituted for my actual username It seems as if the PHP code is not being interpreted at all. Drupal's site mentions that wget or lynx could be used to visit cron.php but from other threads it seemed that a call to that file in the crontab should work. Can anyone shed some light on this for me? Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted July 24, 2008 Share Posted July 24, 2008 I believe wget has been disabled on the servers. I suggest opening a ticket with the help desk and have them take a look at the script. Re-reading your error messages the is a syntax error in the script. That could be the problem. Quote Link to comment Share on other sites More sharing options...
Joaquin Posted July 24, 2008 Author Share Posted July 24, 2008 Hi Bruce, I have actually fixed it! I took a tip from the threads about setting up a cron job to auto backup through cpanel and just added "php" in front of the call to the cron.php file in the crontab and it's working perfectly now. php /home/username/public_html/news/cron.php I'm assuming it needed to know that the file it was going to execute was a PHP and that's why there were syntax errors because it didn't realize it was PHP. Thanks though! Another question though, can I just leave the field for an email address in the cron job section of cpanel blank if I don't want an email sent everytime the cron job executes? Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted July 24, 2008 Share Posted July 24, 2008 Well duh! I should have seen that.... Glad you got it sorted out. And yes, to run a PHP file as a cron job you have to let it know it's going to be executing PHP. Quote Link to comment Share on other sites More sharing options...
Joaquin Posted July 24, 2008 Author Share Posted July 24, 2008 Another question though, can I just leave the field for an email address in the cron job section of cpanel blank if I don't want an email sent everytime the cron job executes? Thanks Bruce, any thoughts on the above question? Joaquin Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted July 24, 2008 Share Posted July 24, 2008 Whoops, sorry missed that. I don't think you can leave that blank it needs to report errors somewhere. You should not receive email unless there is an error or the script you are running is sending email itself. Quote Link to comment Share on other sites More sharing options...
Joaquin Posted July 25, 2008 Author Share Posted July 25, 2008 Hi Bruce, Yes I am getting emails every 15 minutes but the cron job is running and doing the RSS update as it should. The email isn't an error of any sorts it just seems to be the setting of a cookie and, as you say, is coming from the script being run by the cron job: From: Cron Daemon [root@server##.snhdns.com] Set-Cookie: SESSe20e3593e2b2304c0e3b08489ff13539=b42b164f245a7280c21365f8ed4d1372; expires=Sun, 17 Aug 2008 21:33:22 GMT; path=/ Expires: Sun, 19 Nov 1978 05:00:00 GMT Last-Modified: Fri, 25 Jul 2008 18:00:02 GMT Cache-Control: store, no-cache, must-revalidate Cache-Control: post-check=0, pre-check=0 Content-Type: text/html; charset=utf-8 Drupal is one of the programs installed by cpanel and I've been to their support forum with no mention of turning these emails off. I can't even find in the code where the email is getting sent. I guess I'll have to keep looking, need the cron job but can't keep getting emails every 15 minutes. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted July 25, 2008 Share Posted July 25, 2008 Check the cron.php source. Is it sending email each time the job executes? Or is it trying to output information to a browser? I would check with the Drupal people on how to prevent the emails from being sent. cron will only send email if a job fails to run otherwise. Quote Link to comment Share on other sites More sharing options...
brianhulse Posted January 9, 2009 Share Posted January 9, 2009 Joaquin Sorry I didn't see this earlier, but once you have the cron job working sucessfully, simply append " > /dev/null" to the command in your cron job, like this: /usr/bin/php /home/username/public_html/mydrupal/cron.php > /dev/null This redirects the output to the null device. (Posted for future Drupal admins.) Brian Quote Link to comment Share on other sites More sharing options...
stlauc Posted June 18, 2009 Share Posted June 18, 2009 (edited) Crons aren't working for me. curl http://mysite.com/drupal/cron.php used to work. Since I moved the site to root and deleted the /drupal path, cron has failed with this error: <html><head> <title>301 Moved Permanently</title> </head><body> <h1>Moved Permanently</h1> <p>The document has moved <a href="http://www.cifellowship.org/cron.php">here</a>.</p> <hr> <address>Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at cifellowship.org Port 80</address> </body></html> If I run the url from a browser, it works. php /***/****/public_html/cron.php fails with: Status: 404 Not Found Content-type: text/html No input file specified. The path seems fine from the files viewer, cron.php is in the root folder. Thanks Edited June 18, 2009 by TCH-Bruce removed user path info (TCH-Bruce) Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted June 18, 2009 Share Posted June 18, 2009 Welcome to the forums stluc curl has been disabled on the servers. You can use the php line you have above to run it with cron. It should work. If not please open a ticket with the help desk. Quote Link to comment Share on other sites More sharing options...
TCH-Thomas Posted June 18, 2009 Share Posted June 18, 2009 Welcome to the forum, stlauc. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.