Jump to content

Cron Job Help

Recommended Posts

I'm trying to generate a cron job to run the below script, but can't get it to work for the life of me.


#!/usr/local/bin/php -q

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name3 WHERE review_show='n'";
if($num_results > 0){
$message="You have ".$num_results." review unapproved.";
$message="You have ".$num_results." reviews unapproved.";
mail('webmaster@ghosthuntersportal.com','GHP Reviews', $message, 'From: sales@ghosthuntersportal.com');

$sql2="SELECT * FROM $tbl_name4 WHERE rma_issued='n'";
if($num_results2 > 0){
$message="You have ".$num_results2." RMA Number Requested.";
$message="You have ".$num_results2." RMA Numbers Requested.";
mail('webmaster@ghosthuntersportal.com','GHP RMA Number Requests', $message, 'From: sales@ghosthuntersportal.com');
echo "Emails Sent.";



Cron Job Command:

php -f /home/zyquo/public_html/ghosthuntersportal.com/cj_run.php?key=a


I set the time to run every minute, just to try to get this to work... And in the end I get no emails in my inbox.

Link to comment
Share on other sites




Try adding this to the end of your commands.



$result=mysql_query($sql) or mail('webmaster@ghosthuntersportal.com','ERROR', mysql_error(), 'From: sales@ghosthuntersportal.com');



This will let you know of any errors in a mysql query. I have done this on a background task and it helped  a lot.



Have you tried accessing the script via its URL to see if there are any errors?




Link to comment
Share on other sites

Have you ran other php scripts in cron on your server successfully using the syntax you have shown?  If not, you might try this....


In your crontab: (make sure the path to your script is correct and the script has the correct permissions)


*/5 * * * * php -q /CORRECT path to script/cj_run.php?key=a


In the script itself, at least on my servers, I don't use the BASH at the top of the php script.  But like I said, if this has worked in the past, leave it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.