Jul 26, 2008

Cron Job Question

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Others

free web hosting

Cron Job Question

CrazyRob
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:
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...

Reply

Saint_Michael
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 you

http://www.sitepoint.com/article/introducing-cron

it's a series of php scripts and some mysql that should get it going for you.

Reply

CrazyRob
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

Reply

Yacoby
Yup. You need to get the cron job to run the PHP

I use something like this.
CODE
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:
CODE
/usr/bin/php -q /home/yacoby/public_html/path/to/php/file.php > /dev/null


CODE
/usr/bin/php

This is the path to PHP.

CODE
-q

Quite. The > /dev/null might make it so you don't need this.

CODE
/home/yacoby/public_html/path/to/php/file.php

The path from your top directory to the PHP file

CODE
> /dev/null

I think this makes it so that the output is deposed of. Not sure though.



Inclding something like this:
CODE
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.

 

 

 


Reply

CrazyRob
Thanks got it working

Mod close topic

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : cron


    Looking for Cron, Job, Question

Searching Video's for Cron, Job, Question
advertisement



Cron Job Question



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE