Gossamer Forum
Home : General : Databases and SQL :

Run a MySQL statement via cron

Quote Reply
Run a MySQL statement via cron
Hi:

I have a colo server, but my ISP hosts my MySQL... so I do not know mysql too very well at all.

I have a cron job I would like performed on my MySQL data once a month. OK, I can setup the cron just fine, I am just not sure HOW I would send the mysql statement. I know what I would send in the MySQL command boq inMySQLMan... I would send:

update Links set mon_hit = '0'

(I keep my hits tracking cumulative in Links, but I also run a monthly "Most Hits"...- I just want to reset that, and I often forget.)

so the MySQL server is at usersql.aros.net, username dave password links...

Would I want to run a quick perl script, or can I run a command linke in crom to do this? And- this is the biggy!- how would I write the statement?

TIA!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Run a MySQL statement via cron In reply to
You can do either (perl or shell script) or even in PHP.

With a shell script, you would something like the following:

Code:

#!/bin/sh
mysql -u user -p db
update Links set mon_hit = '0';
exit

========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] Run a MySQL statement via cron In reply to
Thank you Eliot!
dave

Big Cartoon DataBase
Big Comic Book DataBase