> I need to build a cache mechanism for a website and I thought I'd use
> 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
Write a shell script to invoke mysql in batch mode and take its input from a
file. Here's one example:
/usr/bin/mysql -h localhost -u username -ppassword database-name
where the file 'commands.sql' contains the SQL statements to clean up the
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
Minnesota Public Radio