Jump to content

Drupal Cron Job


Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 5 months later...

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

Link to comment
Share on other sites

  • 5 months later...

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 by TCH-Bruce
removed user path info (TCH-Bruce)
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...