From: a bv Date: March 6 2012 3:50pm Subject: Script for cleaning data on a regular basis List-Archive: http://lists.mysql.com/mysql/226939 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I found some scripts but i have to edit them to give the true table name to drop. Its format is name1_name2_yearmonth =A0 =A0which year and month here we are talking about is the year and date before the current day . So how can i give this variable to the script? Regards 2012/1/27 walter harms : > > > Am 26.01.2012 18:45, schrieb HalXsz SXndor: >>>>>> 20120126 10:34 AM +0200, a bv >>>> >> Database contains >> tables (structures?) which gets montly data , and these tables are >> named as >> >> name1_name2_ yearmonth . I only want to have the whole database system >> for last 2 years, and automaticly clean the data which became more >> than 2 years old , so i need a script for this (shell, php etc) . Can >> you please help me for this script ? and also which mysql command must >> be used drop, trunk? >> <<<<<<<< >> You can, if you are careful, write an SQL procedure for dropping the app= ropriate tables. Since MySQL has no table variables, if you do this you wil= l need PREPARE. >> >> Therefore, it well may be easier to do it all in PHP, since therewith yo= u can construct statements. The statement "SHOW TABLES" is also a reference= to table INFORMATION_SCHEMA.TABLES; maybe you can use "SHOW TABLES" for a = SELECT statement in PHP; if not, try INFORMATION_SCHEMA.TABLES for their na= mes. >> >> > > This is simple, > consult your manual about crontab. > and start a script like that: > > #!/bin/bash > > mysql -BAN database < > =A0place my great sql-statemant here .... > =A0If you need some additional informationen like $HOME > =A0you can use it also > > EOF > > If something goes wrong a mail will be send to the owner (details > see man 5 crontab) > > re, > =A0wh > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: =A0 =A0http://lists.mysql.com/mysql >