Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Well, CRON again...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
In further reflection to the question I posted on 25/6, I did try to figure out what CRON is by myself, pity there were limited resources available on the net. My understanding is that: CRON is just some kind of application which could perform task at specified dates and times. So how I could know whether the host of my site has this program installed? And, how do I intergrate it with php script something like delete * from ...?
( I would like to keep my database clean). How I'm going to use it? Please treat me as a newbie, please forgive me for my apathy and inertia as well......Thank you very much.

 
OK telnet to your web host and from the command prompt type in
crontab -l (this is L lowercase, not a 1 one)

If you get a list of stuff, you have cron, if not you(probably) don't.
Make a script and upload it containing this:

---------------deletescript.sh----------------------------
use <database_name>;
DELETE FROM table_name WHERE blah etc etc;
-----------------------------------------------------------

Add it to crontab using:
crontab -e

press o to add a new line (make sure you are at the bottom of the file first)add this line.

0 1 * * 1 /path/to/scriptname >/dev/null 2>&1

hold shift and press zz to save and exit.
This line will run your script every 1st day of the month at 01:00AM if you want to find out more about crontab do a search on Google. :) ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
woops make that line:
0 1 * * 1 mysql -u<user> -p<password> < /path/to/scriptname >/dev/null 2>&1 ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top