Neal,

> I need to build a cache mechanism for a website and I thought I'd use
MySQL
> for persistance.  The problem is that I need it to schedule a cleanup task
> every 24 hours - to remove old cache records.  MS SQL Server provides a
> trigger for scheduling such tasks - I am looking for the functional analog
> on MySQL.

Use a CRON job on the server to have mysql execute SQL statements in batch
mode periodically.

Write a shell script to invoke mysql in batch mode and take its input from a
file. Here's one example:

#! /bin/sh
/usr/bin/mysql -h localhost -u username -ppassword database-name
</path/to/commands.sql

where the file 'commands.sql' contains the SQL statements to clean up the
cache.

Then add an entry to your CRONTAB. The following example would run the shell
script at 2am each day:

0 2 * * * /path/to/shellscript

See the CRONTAB manual on your system for details.

If using Windows to run your MySQL server, use the cmd interpreter, the 'at'
command, and the Schedule service. There are versions of CRON available for
Windows, too.

Bruce MacDonald
Minnesota Public Radio


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to