8 replies
I have set up a simple php page on my site to do
some everyday mysql database tasks for updating
the site.

I have run the script from a browser window and it works
however I tried doing a cron and I am not getting an email
to tell me the cron has been done and looking at the site it
looks like it hasn't been used.

I have tried both of these in my cron set up:

php -q /home/XXXXXX/public_html/cron_XXXXXX.php > /dev/null

/usr/bin/GET http://www.XXXXXXXX.com/cron_XXXXXX.php

I set the cron job to run at:

0 minutes
every other hour
every day
every month
every weekday

Niether appear to be working.

This is a short excert from the script:

include 'system/config.php';
include 'system/opendb.php';

mysql_query("UPDATE `XXXXXX`.`XXXXX` SET `intCategory` = '131' WHERE `intAuthorId` =39930
AND `intStatus` =0")
or die(mysql_error());

mysql_query("DELETE FROM `XXXXXX`
WHERE `textArticleText` LIKE CONVERT( _utf8 '%www.%'
USING latin1 )
COLLATE latin1_swedish_ci
or die(mysql_error());

include 'system/closedb.php';

As I say the script works OK from a browser window so has anyone any idea
what I may be doing wrong.

Any help much appreciated.


#cron #job #php #problem
  • Profile picture of the author theIMgeek
    Since your script is publicly accessible, here's an option for your cron command:
    lynx -dump http://www.somedomain.com/cron.php

    That will open the page using the lynx browser on the server, just as if it was a person viewing the page.

    If that still doesn't do it, then perhaps the question is whether or the cron service is actually running.

    FREE WSO: Protect and Automatically Deliver Your Digital Products

    Ask the Internet Marketing Geek
    <-- Happy to help with technical challenges
    MiniSiteMaker.org <-- Free software to make your mini-sites fast and easy
    {{ DiscussionBoard.errors[2690814].message }}
  • Profile picture of the author nevadasoft
    The reason your original cronjob wasn't working is because of the "include" command. The path is different when running under cron. If you want it to work without lynx just replace the "include" commands with the actual content, or specify the correct path.
    {{ DiscussionBoard.errors[2710193].message }}
  • Profile picture of the author circus_freak
    use another cron syntax
    {{ DiscussionBoard.errors[2714673].message }}
  • Profile picture of the author mogol87
    use hostgator as a webhost! they provide accurate assistant when it comes to cron job!
    {{ DiscussionBoard.errors[2718888].message }}
  • Profile picture of the author jminkler
    In your cron, be sure you are running the right php, check your hosting's recommended php to use.

    also you can cd to the folder before executing the script, this will make your includes correct again

    * * * * * * * cd /path/to/script; /usr/bin/php myscript.php >/dev/null 2>&1
    {{ DiscussionBoard.errors[2719139].message }}

Trending Topics