Author Topic: [SOLVED] Cron job probs  (Read 10368 times)

Offline ProwlingTiger

[SOLVED] Cron job probs
« on: May 23, 2007, 07:38:13 am »
Okay, I set up a cron job with the dointerest.php file. I dont have cpanel, but it should work, shouldnt it?

My interest doesnt run, and I'm getting this error in my email daily:

Code: [Select]
sh: line 1: php: command not found

Cron Job:
Code: [Select]
php /home/***/www/forums/sources/shop/dointerest.php
dointerest.php:
Code: [Select]
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2005 DanSoft Australia           |
|      http://www.dansoftaustralia.com/        |
\**********************************************/

//File: dointerest.php
//      The file to add interest to member's bank

//VERSION: 1.31 (Build 7)
//DATE: 10th December 2005
// $Id: dointerest.php 4 2006-07-08 10:09:08Z daniel15 $

if(!isset($_SERVER["HTTP_HOST"])) {

include("../../SSI.php");

$interest_rate $modSettings['shopInterest'] / 100;
db_query("UPDATE {$db_prefix}members
  SET moneyBank = moneyBank + (moneyBank*
{$interest_rate})"__FILE____LINE__);

echo "Interest added at ".date("d/m/Y h:i:s A");
}
?>


I'd be more than willing to provide whatever files necessary to get this working.

-Dano

Offline David

Re: Cron job probs
« Reply #1 on: May 23, 2007, 06:28:50 pm »
 It sounds to me as though your server isn't configured to run php in a cron job...however there's an easy work-around already coded and offered by Daniel.

http://www.daniel15.com/forum/index.php/topic,31.0.html

 The file Daniel offered there can be called via a cron job and will then get around the server restriction.

 Use the following command:

wget -O - -q http://www.<your site>/<yourfile>.php

 Basil Beard also offered a possible solution in the discussion on the link I gave above...there are several ways you could do it.

 Hope this helps.

Offline Daniel15

Re: Cron job probs
« Reply #2 on: May 26, 2007, 10:02:52 am »
Instead of just "php", try /usr/bin/php and /usr/local/bin/php:
Code: [Select]
/usr/bin/php /home/***/www/forums/sources/shop/dointerest.php

Offline feeble

Re: Cron job probs
« Reply #3 on: May 26, 2007, 07:31:05 pm »
Instead of just "php", try /usr/bin/php and /usr/local/bin/php:
Code: [Select]
/usr/bin/php /home/***/www/forums/sources/shop/dointerest.php

prowling is with dreamhost
http://wiki.dreamhost.com/Cron#Executing_a_PHP_Script_with_Crontabs

Offline ProwlingTiger

Re: Cron job probs
« Reply #4 on: May 31, 2007, 05:16:42 am »
Instead of just "php", try /usr/bin/php and /usr/local/bin/php:
Code: [Select]
/usr/bin/php /home/***/www/forums/sources/shop/dointerest.php
Hmm..I tried that. I'm going to try feeble's suggestion now. I cant believe I missed that page of the wiki

Offline ProwlingTiger

Re: Cron job probs
« Reply #5 on: May 31, 2007, 06:09:28 am »
Okay...I am really fed up with this. I'm pretty sure I've tried everything mentioned. If someone wants to be so kind and offer help, I can set up a FTP account, and whatever else to try and get this darn thing working.

Offline David

Re: Cron job probs
« Reply #6 on: May 31, 2007, 08:02:30 am »
I've been following your progress as I also use Dreamhost and, if you look at my earlier reply I gave you the way I got it to do what I needed.

 I too wasted far too much time trying to sort out other methods and eventually decided to use the easy way out and not be too bothered about it.

Offline ProwlingTiger

Re: Cron job probs
« Reply #7 on: May 31, 2007, 08:21:25 am »
I've been following your progress as I also use Dreamhost and, if you look at my earlier reply I gave you the way I got it to do what I needed.

 I too wasted far too much time trying to sort out other methods and eventually decided to use the easy way out and not be too bothered about it.
Hmm..but you got it to work right? Mind if I send you screenshots of what I've got so far?

Offline David

Re: Cron job probs
« Reply #8 on: May 31, 2007, 08:30:41 am »
Not at all...and yes I've got it working with no problems thus far.

 Just to make sure you're setting the file up properly...

Code: [Select]
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2005 DanSoft Australia           |
|      http://www.dansoftaustralia.net/        |
\**********************************************/

//File: dointerest.php
//      The file to add interest to member's bank

//VERSION: 1.31 (Build 7)
//DATE: 10th December 2005

include("/home/.<server name>/<shell user name>/<domain name in the form of abc.com>/<directory for forum if not in root>/SSI.php");

$interest_rate $modSettings['shopInterest'] / 100;
db_query("UPDATE {$db_prefix}members
SET moneyBank = moneyBank + (moneyBank*
{$interest_rate})"__FILE____LINE__);

echo 
"Interest added at ".date("d/m/Y h:i:s A");
?>
« Last Edit: May 31, 2007, 08:45:22 am by David »

Offline ProwlingTiger

Re: Cron job probs
« Reply #9 on: June 01, 2007, 12:29:01 am »
Okay, well I woke up this morning and got an email saying it auto added interest. Cant tell you how much it pisses me off, as I have no clue what was wrong with it. But at least it works now. Thanks everyone for the help!

Offline Daniel15

Re: Cron job probs
« Reply #10 on: June 01, 2007, 06:46:00 pm »
Your host should have an option to discard the message, rather than email it to you.
Otherwise, just remove this line from the PHP file:
Code: [Select]
echo "Interest added at ".date("d/m/Y h:i:s A");
This should not harm it in any way :)

Offline ProwlingTiger

Re: Cron job probs
« Reply #11 on: June 02, 2007, 01:20:19 am »
Yeah I was considering removing that line, but now that I look, I've found the email notification option in my CP.

Offline Earache

Re: [SOLVED] Cron job probs
« Reply #12 on: June 08, 2007, 07:24:31 am »
I tried to install using the regular cron job but no go.
I tried the script from above and no go
It keeps telling me
Quote
No such file or directory in /home/.c**/***/www.minemine.org/

SMF is installed in root folder along with TinyPortal, web host is Dreamhost, any ideas?

Offline Daniel15

Re: [SOLVED] Cron job probs
« Reply #13 on: June 08, 2007, 08:06:43 pm »
Is the path you're using correct? Go to the server settings part of the SMF admin panel, and check that the path is correct (if /home/.c**/***/www.minemine.org/ is the right path).

Offline Earache

Re: [SOLVED] Cron job probs
« Reply #14 on: June 09, 2007, 01:24:49 am »
I copy and pasted that from admin > SMF directory