CrazyRob 0 Report post Posted January 11, 2007 Ok i need to execute an sql query at a certain time of day and they only way i think this can be achieved is through a cron. The only problem is that i haven't a clue how to do it.Code: UPDATE trap17_ipbmembers SET points = points - 1 WHERE mgroup = 3 thats the SQL code but i need that executed at a certain time on a certain database every day. can anyone help me as i have know knowledge of cron what so ever - have a fealing i need to do that database bit in php but im not sure what code to put in as it will interact with cron.Help... Share this post Link to post Share on other sites
Saint_Michael 3 Report post Posted January 12, 2007 I am assuming your not using cpanel, if you are you could set them up that way. any ways I thought I toss this little code up for youhttps://www.sitepoint.com/introducing-cron/it's a series of php scripts and some mysql that should get it going for you. Share this post Link to post Share on other sites
CrazyRob 0 Report post Posted January 12, 2007 well i am using cpanel. cpanel cant execute sql queries from cron so id need a php script that had all the data in it then set cron to run the php script at a certain time of day Share this post Link to post Share on other sites
Yacoby 0 Report post Posted January 12, 2007 (edited) Yup. You need to get the cron job to run the PHPI use something like this. 0 0 * * * /usr/bin/php -q /home/yacoby/public_html/path/to/php/file.php > /dev/null (If you set up the cron job under the Unix style interface, you will see that there are boxs for the 0s and *s, and then one big text input for this:/usr/bin/php -q /home/yacoby/public_html/path/to/php/file.php > /dev/null /usr/bin/phpThis is the path to PHP.-qQuite. The > /dev/null might make it so you don't need this./home/yacoby/public_html/path/to/php/file.phpThe path from your top directory to the PHP file> /dev/nullI think this makes it so that the output is deposed of. Not sure though.Inclding something like this:if ($REQUEST_URI){ print "Access forbidden!<br>"; exit;} At the top of the script would, I think, make it so the script can't be run from your browser, it has to be run via the cron job.Hopefully this will have helped. I don't know very much at all on this subject. Edited January 12, 2007 by Yacoby (see edit history) Share this post Link to post Share on other sites
CrazyRob 0 Report post Posted January 13, 2007 Thanks got it workingMod close topic Share this post Link to post Share on other sites