At 01:54 PM 6/17/2003 -0400, Michael Cortes wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello. I am a new member to this list. I would like to run an sql query as a
cron job and can't figure out how. Here is some background.


I have mysql loaded on several of our linux servers.  I currently use
mysqldump in a cron job in conjuction with logrotate as a backup method.  I
like the ascii files I get as a result and can work with them easier than
more traditional methods of backup.

I user the mysql command quite often with sql commands searching for db
entries.  I always enter these sql commands after getting into the mysql
command prompt..  I also know exactly what sql statement I want to execute.
I have succesfully executed it from both the mysql command prompt and from
Mysql control center.

However, I do not know how to execute an sql statement from the linux command
prompt.  If I could this, I could easily enter it into the crontab or cron
scripts as needed.

Help would be greatly appreciated.

Thank you.



- --

Michael Cortes
Fort LeBoeuf School District
34 East Ninth Street
PO Box 810
Waterford PA 16441-0810
814.796.4795

create 3 file 1.1 file for crontab such as mycron in mycron look like this # min(0-59) hour(0-23) date(1-31) month(1-12) dow(0=sun) command # daily at 00:00 run myupdate at /usr/local 0 0 * * * /usr/local/mysql/data/myupdate

1.2 file for crontab call such as myupdate in myupdate look like this
/usr/local/mysql/bin/mysql -ppasswd_of_root < /usr/local/mysql/data/myscript


        1.3 file for myupdate call such as myscript in myscript look like this
        update xxxx set yy='zz' where aa='bb';

and then instal crontab by
crontab -e mycron

to see your setting by
crontab -l

and now every 00:00 a.m. Linux will cal MySQL to do that you want

Kittiphum Worachat

Reply via email to