[CS-FSLUG] Cron job to empty a db
Frank Bax
fbax at sympatico.ca
Thu Jul 7 08:25:17 CDT 2005
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
More information about the Christiansource
mailing list