[CS-FSLUG] Cron job to empty a db

David M david at davidcentral.net
Mon Jul 11 06:45:29 CDT 2005


On Thursday 07 July 2005 09:25 am, Frank Bax wrote:
> At 10:44 PM 7/6/05, David M wrote:
> >Hey all,  could anyone tell me if it Is possible to set up a cron job to
> >empty
> >a database table at certain intervals?
> >
> >If so would anyone know a simple script to do so?
>
> No need for script.  Both mysql and pgsql allow you to include an SQL
> statement as an argument; therefore, it's a one liner.  Here's an example
> where I issue "flush tables" in mysql:
>
> 50 23 * * *  echo 'flush tables' | mysql -u root --password=rootpswd
>
> Reading 'man mysql', I see I could have also done it with '-e' option.  I
> have done this with -c option of pgsql, but can't find an example right
> now.

Frank, Thanks for the help. I'm going to use something like this to keep the 
recent referers database emtpy to try and keep spam down on my blog. 

My first step was to do something with the comment spam, and so I started 
requiring people who leave a comment on my blog to become a member first and 
that actually did cut out 100% of the comment spam.

But I don't want this to be a permenant solution but it is working for the 
time being.

David M.




More information about the Christiansource mailing list