Jump to content

Cron jobs


smith.james0

Recommended Posts

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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....)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.