smith.james0 Posted May 8, 2006 Share Posted May 8, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/9330-cron-jobs/ Share on other sites More sharing options...
.josh Posted May 8, 2006 Share Posted May 8, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/9330-cron-jobs/#findComment-34427 Share on other sites More sharing options...
smith.james0 Posted May 9, 2006 Author Share Posted May 9, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/9330-cron-jobs/#findComment-34719 Share on other sites More sharing options...
smith.james0 Posted May 11, 2006 Author Share Posted May 11, 2006 Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/9330-cron-jobs/#findComment-35173 Share on other sites More sharing options...
Zubaz Posted May 11, 2006 Share Posted May 11, 2006 looks like your connection script ain't right. Quote Link to comment https://forums.phpfreaks.com/topic/9330-cron-jobs/#findComment-35174 Share on other sites More sharing options...
.josh Posted May 11, 2006 Share Posted May 11, 2006 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....) Quote Link to comment https://forums.phpfreaks.com/topic/9330-cron-jobs/#findComment-35188 Share on other sites More sharing options...
smith.james0 Posted May 12, 2006 Author Share Posted May 12, 2006 I have this is the cron control panel/home/********/public_html/cron/delete_ppl_online.php>/dev/nullIs this right?Do you have to chmod it?Many thanks James Quote Link to comment https://forums.phpfreaks.com/topic/9330-cron-jobs/#findComment-35279 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.