Cron help..

Status
Not open for further replies.

RaverBaloo

New Member
Messages
4
Reaction score
0
Points
0
well im not sure if this is where is should post this or not. But i am using the free host and i need some help setting up a cron or at least a push in the right direction to see if it is working or to make it work. I was looking on line and i saw that there was two different set of codes for the cron...
php -q /home/server/public_html/script
/usr/local/bin/php -q /home/server/public_html/script

So do i use one of those or do i use something different?

I also have it set up for every 10 min atm.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Code:
/usr/bin/php /home/igor/public_html/script.php >>/home/igor/public_html/log.txt 2>&1

Replace "igor" with your cPanel username.

You can actually have the script and log file anywhere below /home/igor (to keep it from being accessible from the Web, if you so wish).

This will log any errors/output to log.txt so you can monitor the job. If the output makes the log grow too big too fast, just remove the
Code:
 >>/home/igor/public_html/log.txt 2>&1
 

RaverBaloo

New Member
Messages
4
Reaction score
0
Points
0
Ok thank you ill try this now :D

Ok so when i waited the 10 min, i got the log.txt but the db entry that i have to update isnt updating.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
You can try posting your code between [ PHP ] tags.

What does the log file say?

Does the script work if you call it from the Web?
 
Last edited:

RaverBaloo

New Member
Messages
4
Reaction score
0
Points
0
Yes it does work when i call it by going to the URL in the browser that is why i wanted to cron it.
Well right now it is a simple code but it is:
PHP:
<? include_once ("safe.php"); ?>
<? include ("left.php"); ?>
<?php

   if($energy < 100)
   {
     $energy = $energy + 5;
     $sql=mysql_query("UPDATE users SET energy='$energy' where name='$name'");
  }

?>


The log file says:
Status: 302 Moved Temporarily
Set-Cookie: PHPSESSID=r218pehgfdlnt2m2gm8aovmel5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: index.php
Content-type: text/html
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
The log file is, I assume because one of your includes has a header redirect to index.php

Where does $energy and $name come from?
 

RaverBaloo

New Member
Messages
4
Reaction score
0
Points
0
They come from my database. I know i am able to access them because i can echo their values.
 
Status
Not open for further replies.
Top