SMF Shop

SMFShop => Installation Problems => Topic started by: ProwlingTiger on May 23, 2007, 07:38:13 am

Title: [SOLVED] Cron job probs
Post by: ProwlingTiger 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
Title: Re: Cron job probs
Post by: David 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 (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.
Title: Re: Cron job probs
Post by: Daniel15 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
Title: Re: Cron job probs
Post by: feeble 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
Title: Re: Cron job probs
Post by: ProwlingTiger 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
Title: Re: Cron job probs
Post by: ProwlingTiger 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.
Title: Re: Cron job probs
Post by: David 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.
Title: Re: Cron job probs
Post by: ProwlingTiger 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?
Title: Re: Cron job probs
Post by: David 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");
?>
Title: Re: Cron job probs
Post by: ProwlingTiger 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!
Title: Re: Cron job probs
Post by: Daniel15 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 :)
Title: Re: Cron job probs
Post by: ProwlingTiger 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.
Title: Re: [SOLVED] Cron job probs
Post by: Earache 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?
Title: Re: [SOLVED] Cron job probs
Post by: Daniel15 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).
Title: Re: [SOLVED] Cron job probs
Post by: Earache on June 09, 2007, 01:24:49 am
I copy and pasted that from admin > SMF directory
Title: Re: [SOLVED] Cron job probs
Post by: Daniel15 on June 09, 2007, 10:36:52 am
In that case, make sure you add the correct path to the end of it.  In your case, I think it'd be /home/.c**/***/www.minemine.org/Sources/shop/dointerest.php :)
Title: Re: [SOLVED] Cron job probs
Post by: Earache on June 09, 2007, 02:11:11 pm
Its not working for me.
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");
?>
This one just says
Quote
Warning: include(/home/.caracal/lucapit/minemine.org/Sources/shop/dointerest.php) [function.include]: failed to open stream: No such file or directory in /home/.caracal/lucapit/www.minemine.org/Sources/shop/dointerest.php on line 14

Warning: include() [function.include]: Failed opening '/home/.caracal/lucapit/minemine.org/Sources/shop/dointerest.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/.caracal/lucapit/www.minemine.org/Sources/shop/dointerest.php on line 14

Fatal error: Call to undefined function db_query() in /home/.caracal/lucapit/www.minemine.org/Sources/shop/dointerest.php on line 17

and the orignal one does absolutely nothing.
Any idea? :(
Title: Re: [SOLVED] Cron job probs
Post by: Daniel15 on June 10, 2007, 12:37:54 pm
Quote
Warning: include(/home/.caracal/lucapit/minemine.org/Sources/shop/dointerest.php) [function.include]: failed to open stream: No such file or directory in /home/.caracal/lucapit/www.minemine.org/Sources/shop/dointerest.php on line 14

In the interest PHP file, change minemine.org to www.minemine.org :)
Edit: Just so I don't confuse you :P, the line in dointerest.php should look like:

include('/home/.caracal/lucapit/www.minemine.org/SSI.php');
Title: Re: [SOLVED] Cron job probs
Post by: Earache on June 11, 2007, 10:54:21 am
yay it worked!!

Thanks Daniel, amazing script!!