Jump to content

[SOLVED] problem with cron


desithugg

Recommended Posts

Umm I have a cron setup using cPanel

Every Minute,Every Hour,Every Day,Every Week,Every Month

command: /home/pcaworld/public_html/timer.php

 

<?php
//timer.php
mysql_connect("localhost", "********", "******") or die(mysql_error());
mysql_select_db("pcaworld_rpg") or die(mysql_error());
$st = rand(1,300);
$query = mysql_query("update other set answer = '$st' where question = 'orb'") or die(mysql_error()); 
?>

Well it's just to test if the cron job thing works

Also I have an email specified that the cron output is sent to and this is what i keep getting in the email

/bin/sh: /home/pcaworld/public_html/timer.php: Permission denied

and when i check the database nothing has changed umm is there any reason why it keeps saying that?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/45493-solved-problem-with-cron/
Share on other sites

It needs a shabang.

 

#!/usr/bin/php
<?php
  mysql_connect("localhost", "********", "******") or die(mysql_error());
  mysql_select_db("pcaworld_rpg") or die(mysql_error());
  $st = rand(1,300);
  $query = mysql_query("update other set answer = '$st' where question = 'orb'") or die(mysql_error()); 
?>

 

PS; Make sure /usr/bin/php is a valid path to php. (In most cases it will be)

umm yea that seemed to be the problem well i redid the command to

wget -O /dev/null http://pcaworld.net/timer.php‎

and i got the response

--23:19:01--  http://pcaworld.net/timer.php          => `/dev/null'Resolving pcaworld.net... 38.100.22.223Connecting to pcaworld.net|38.100.22.223|:80... connected.HTTP request sent, awaiting response... 200 OKLength: unspecified [text/html]    0K                                                          0.00 B/s 23:19:05 (0.00 B/s) - `/dev/null' saved [0]

in the email however nothing in the database seemed to be changed.

I tried

/usr/bin/php -q /home/pcaworld/public_html/timer.php

php -q /home/pcaworld/public_html/timer.php

/usr/bin/php -f /home/pcaworld/public_html/timer.php

php -f /home/pcaworld/public_html/timer.php

 

and none of those worked well i tried those and didn't get any email or anything either.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.