Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page cron job problem, not working at all
Reply
 
Thread Tools Display Modes
(#1)
Old
KillerBeeZ KillerBeeZ is offline
Junior Member
KillerBeeZ is on a distinguished road
 
Posts: 3
Join Date: May 2012
Default cron job problem, not working at all - 05-20-2012, 06:57 PM

the cron job is listed as this...

*/5 0 * * * php -f /home/a5******/public_html/pancron.php

pancron.php

Quote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php
$url ='http://www.ctlinx.com/org/panprix/admin/php/pancron.php';
header('Location: '.$url);
?>
</body>
</html>
and that points to...

Quote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?
$user="a5818989_pan";
$password=Deleted by moderator;
$database="a5818989_pan";
mysql_connect("mysql7.000webhost.com",$user,$passw ord);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM cron";

$result=mysql_query($query);
$num=mysql_num_rows($result);

$counter = mysql_result($result,$i,"counter");
$counter = $counter +1;

$query2 = "UPDATE cron SET counter = '$counter'";
mysql_query($query2);
mysql_close();

echo "$counter";
?>
</body>
</html>
I'm fairly new to cron jobs. I have tried it several ways including...

every 15 minutes, I used several ways to point to the script I need run (due to the fact that I read the script cannot be on the same page the cron job points to, I did have it set there too and it didn't work.

I know the script works as when I go to that page the counter goes up. I plan to create a racing game and will do so as soon as I can get the cron job to work properly, I will also be paying for the better hosting service but I want to get the game at least 90% done first.

What am I doing wrong here?

and thank you in advance for any help you can provide.

Last edited by d3iti; 05-20-2012 at 07:05 PM.
Reply With Quote
(#2)
Old
d3iti's Avatar
d3iti d3iti is offline
Super Moderator
d3iti is on a distinguished road
 
Posts: 7,491
Join Date: Jul 2009
Location: Spain
Default 05-20-2012, 07:16 PM

Hello,

I do not understand why you are using two files and I think you do not have very clear how you must use the cron.

Have you tried to run your second script directly to see if it work well?
I think your second "script file" contains errors.

What do you want to get when you run the cron?


Recuerda realizar copias de seguridad de tus sitios web. Si este mensaje te ayudó puedes pulsar sobre el botón karma
Reply With Quote
(#3)
Old
KillerBeeZ KillerBeeZ is offline
Junior Member
KillerBeeZ is on a distinguished road
 
Posts: 3
Join Date: May 2012
Default 05-20-2012, 07:36 PM

I tried it with 1 file, still didn't work
I just want the counter to go up by one for now, once its working I can add what I need to it later
the second script does indeed work try it for yourself http://www.ctlinx.com/org/panprix/admin/php/pancron.php
I also did mention that I am new to cron so yeah I'm sure you're right in that I don't know it very well

[1 minute later]

oh and thank you for deleting the password, I didn't realize it was in there... I will change it now anyway to be sure

Last edited by d3iti; 05-20-2012 at 07:50 PM.
Reply With Quote
(#4)
Old
d3iti's Avatar
d3iti d3iti is offline
Super Moderator
d3iti is on a distinguished road
 
Posts: 7,491
Join Date: Jul 2009
Location: Spain
Default 05-20-2012, 07:49 PM

I do not know much about cron, but I think the cron tool is used for internal processes within the server (back up the database, cleaning temporary files, etc), but I think it is wrong to use it to generate an HTML page, because the cron can not display a page a visitor/user of your website.

I think you should try with schemes such as "javascript" or "labels in head" to reload the website from time to time.

I'll move this thread to the "Web programming". Surely there are more users that can help to resolve your issue.


Recuerda realizar copias de seguridad de tus sitios web. Si este mensaje te ayudó puedes pulsar sobre el botón karma
Reply With Quote
(#5)
Old
KillerBeeZ KillerBeeZ is offline
Junior Member
KillerBeeZ is on a distinguished road
 
Posts: 3
Join Date: May 2012
Default 05-20-2012, 07:56 PM

ok thank you, Though I am not intending to generate a page using cron, It is ok if it is never seen by anyone as long as the counter goes up and is saved to SQL, eventually I plan to use it only to make a timer count down so that I can start races automatically without anyone having to log on and do it manually. I looked into javascript but it just seemed overly complicated and figured it would be a lot easier just to use a cron job
Reply With Quote
(#6)
Old
Lucius Lucius is offline
Junior Member
Lucius is on a distinguished road
 
Posts: 3
Join Date: May 2012
Default 05-28-2012, 01:30 AM

If I'm not mistaken, the header function for php cannot be called after any html has been written. For that reason, your first page will NOT link to the second.
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

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com