Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page Cron jobs not working on the free hosting version
Reply
 
Thread Tools Display Modes
(#1 (permalink))
Old
Junior Member
Azakaru is on a distinguished road
 
Posts: 8
Join Date: Jul 2012
Default Cron jobs not working on the free hosting version - 07-27-2012, 06:14 PM

Hello everyone, and thank you for reading my post. I started hosting an Mccode server on my account, which has worked out just fine, but the cron jobs do not seem to want to work, either that, or I'm just asting your time here q.q . I wanted to use a cron job every 5 or minutes, tried it on diffrent time intervals and it still didn't work.
The Cron I want to activate is energy regeneration, which seems to stay at 0 even if the cronjob is on. This is the code inside the cron itself:
PHP Code:
require_once(dirname(__FILE__) . "/../mysql.php");
require_once(
dirname(__FILE__) . "/../global_func.php");
$cron_code 'a57d16b7cad75b14ba73ecf03859e80a';
if (
$argc == 2)
{
    if (
$argv[1] != $cron_code)
    {
        exit;
    }
}
else if (!isset(
$_GET['code']) || $_GET['code'] !== $cron_code)
{
    exit;
}
// update for all users
$allusers_query =
        
"UPDATE `users`
        SET `brave` = LEAST(`brave` + ((`maxbrave` / 10) + 0.5), `maxbrave`),
        `hp` = LEAST(`hp` + (`maxhp` / 3), `maxhp`),
        `will` = LEAST(`will` + 10, `maxwill`)"
;
mysql_query($allusers_query$c);
//enerwill update
$en_nd_query =
        
"UPDATE `users`
        SET `energy` = `maxenergy`
        WHERE `donatordays` = 0"
;
$en_don_query =
        
"UPDATE `users`
        SET `energy` = LEAST(`energy` + (`maxenergy` / 6), `maxenergy`)
        WHERE `donatordays` > 0"
;
mysql_query($en_nd_query$c);
mysql_query($en_don_query$c); 

In the following 2 pictures you can see what the cron's path is and what path I used in the cronjobs menu.
Quote:
1.
2.
I would ask you to please try and see if what I did wrong and help me with steps to make this cron work properly:| .


~Peace

Last edited by Azakaru; 07-27-2012 at 06:16 PM.
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
chanh's Avatar
Administrator
chanh is on a distinguished road
 
Posts: 2,010
Join Date: Dec 2008
Default 07-27-2012, 07:06 PM

Usually, cron issue are relate to the script not able to adapt to how and where it is run. search for cron and you will have lot of resource regarding issue.
Reply With Quote
(#3 (permalink))
Old
Junior Member
Azakaru is on a distinguished road
 
Posts: 8
Join Date: Jul 2012
Default 07-28-2012, 12:13 AM

ookay then, could you or someone please write me a script that sets energy for every user to be equal to maxenergy, or to be increased by a certain value (idk how much, I just want to see the script) ?


~Peace
Reply With Quote
(#4 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 733
Join Date: Dec 2010
Default 07-28-2012, 10:27 AM

maxbrave, maxhp, maxwill and maxenergy are seperate field names? or defined somewhere else?
Would you please manually execute cron_fivemins.php by entering:

http://yourdomain.com/crons/cron_fivemins.php, and see if it works.

If you want to run the cron job every five minutes the frequency should be set up:

*/5 * * * *

In my case, cron jobs which worked several months ago, are not working these days
in 000webhost.com server. This means that you need to wait until admin people solve
this problem.

Last edited by grace1004; 07-28-2012 at 10:34 AM.
Reply With Quote
(#5 (permalink))
Old
Junior Member
Azakaru is on a distinguished road
 
Posts: 8
Join Date: Jul 2012
Default 07-28-2012, 12:02 PM

I tried a lot of times to manually execute it but it's of no use... Nothing happens:/ as to if they are defined in diffrent files, I don't really know... Also, where to put the */5 * * * and that kind of crons? When I installed mccode (a customisable source) it told me something about further configuring cron jobs, 4 diffrent timers, for 1 minute 5 minutes, an hour and a day, followed by the paths to the crons and some codes... As you can see, it says something about that code in the script I posted but I don't know what that is


~Peace
Reply With Quote
(#6 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 733
Join Date: Dec 2010
Default 07-28-2012, 12:52 PM

15 0 * * *--means 0:15 AM (midnight), every day, every month, every week day.

Minimum interval which can be set up in free hosting is every 5 minutes; every 1 minute
is not allowed.

In your CPanel, click 'Cron Jobs' icon - You will get 'Cron Jobs Manager' showing some
example how to set up intervals. You can set up intervals on 'Add new Cron Job' form
placed next to Cron Jobs Manager.

Before setting up your cron job, you need to correct your script first. Did you write
the code by yourself? I need your answer to my question in my previous post above.

Last edited by grace1004; 07-28-2012 at 12:58 PM.
Reply With Quote
(#7 (permalink))
Old
Junior Member
Azakaru is on a distinguished road
 
Posts: 8
Join Date: Jul 2012
Default 07-28-2012, 02:18 PM

I didn't write it by myself... the code was taken from http://mccodes.com/products.php?id=2 as a shared game ... can you look at that please? It's free and it's a standalone source... It's just that the crons don't work :/


~Peace
Reply With Quote
(#8 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 733
Join Date: Dec 2010
Default 07-28-2012, 02:32 PM

To upload game contents is not allowed in free hosting plus currently cron jobs are not
working either. If you really want to run game site, I recommend to upgrade to premium
account.
Reply With Quote
(#9 (permalink))
Old
Junior Member
Azakaru is on a distinguished road
 
Posts: 8
Join Date: Jul 2012
Default 07-28-2012, 02:44 PM

oh, I see... but can you at least tell me how the script should look like? :/


~Peace
Reply With Quote
(#10 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 733
Join Date: Dec 2010
Default 07-29-2012, 03:13 AM

It seems that paths for required files are not correct.
Please try again after changing as follows:

From:
require_once(dirname(__FILE__) . "/../mysql.php");
require_once(dirname(__FILE__) . "/../global_func.php");

To:
require_once(dirname(__FILE__) . '/' . 'mysql.php');
require_once(dirname(__FILE__) . '/' . 'global_func.php');
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com