Jump to content


Photo

Cron jobs


  • Please log in to reply
6 replies to this topic

#1 smith.james0

smith.james0
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 08 May 2006 - 07:23 PM

I want to create a php cron job. I but i don't know much about them, do you just write it as a normal php file?

Thanks James

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 08 May 2006 - 09:22 PM

yes. you write your php script the way you would do any php script. have it do whatever you want it to do. Some people throw in some security on the script, like checking to see if the IP address trying to access the page is only the server's IP address, and you can also change the CHMOD on it for read only by server. stuff like that. I guess it depends on what the script is for, as to how secure you want it.

then you go to cpanel and setup the cron job for how often you want your script to be run. or you can do it on command line through shell.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 smith.james0

smith.james0
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 09 May 2006 - 07:21 PM

I am trying to get to work the People on line script from this site. The last page has this

<?
// Database connection information here

$maxtime = time() -600;
$sql = mysql_query("DELETE FROM ppl_online WHERE UNIX_TIMESTAMP(activity) < '$maxtime'");
$rows = mysql_affected_rows();

echo "Total of $rows Deleted";
?>


It work ok if you call the page but when it's done via cron, I get this email.

/home/*********/public_html/cron/delete_ppl_online.php: line 1: ?: No such file or directory
/home/*********/public_html/cron/delete_ppl_online.php: line 2: //: is a directory
/home/*********/public_html/cron/delete_ppl_online.php: line 4: syntax error near unexpected token `"localhost",'
/home/*********/public_html/cron/delete_ppl_online.php: line 4: ` $db=mysql_connect ("*********", "*********", "*********") or die ('I cannot connect to the database because: ' . mysql_error());'

Any ideas, Thanks James


#4 smith.james0

smith.james0
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 11 May 2006 - 06:53 AM

Can anyone help?

#5 Zubaz

Zubaz
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 11 May 2006 - 06:55 AM

looks like your connection script ain't right.

#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 11 May 2006 - 07:32 AM

if the script works fine when you call it in your browser, then it is not a connection issue.

the error is fairly straightforward. it's telling you that the directory you put in your command does not exist. make sure in your cron job command it points to the proper directory that your script is in (no typos in the folder names, pointing to the right folder, etc....)
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#7 smith.james0

smith.james0
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 12 May 2006 - 08:14 PM

I have this is the cron control panel

/home/********/public_html/cron/delete_ppl_online.php>/dev/null


Is this right?

Do you have to chmod it?

Many thanks James




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users