cronjob to remove gallery2 spam

cronjob to remove gallery2 spam

Posted by: dalemarsden
Posted on: 2007-07-17 22:33:00

So, I'm a bigtime newb on cron, sql, etc. I'm getting a big load of spam on my gallery2. I found a nice sql query (http://gallery.menalto.com/node/55331) to remove all of this, and it works like a charm when I run it as a query in phpmyadmin.

But I want to automate this as a cronjob so I don't have to do it manually every few hours. I know the cronjob interface in the DH control panel, but I can't seem to get the command I'm supposed to put as the command. Here's what I've tried (with everything in ALLCAPS replaced as appropriate)

mysql -h HOST -u USER -p PASSWORD gallery2sql < /home/USER/misc/utilities/removespam.txt

The file is just a text file containing the sql query. But this doesn't work. Likewise, following the DH wiki crontab entry, I tried with /usr/bin/mysql instead of just mysql, but no dice.

Can anyone help, and tell me what's wrong?


Re: cronjob to remove gallery2 spam

Posted by: rlparker
Posted on: 2007-07-17 23:02:00

I don't have a lot of experience with what you are trying to do, particularly with building the query taking input from the file, but don't you need the -e option to "execute" the query?

From the MySQL Manual:

"Another option that may occasionally be useful with mysql is the --execute or -e option, which can be used to pass SQL statements to the server. When this option is used, mysql executes the statements and exits. The statements must be enclosed by quotation marks. "

Have you considered writing a php program to execute the query, and executing *that* via cron, as described in the Wiki Article (that *might* be easier to do shocked)?

--rlparker

Tags: cronjobsql querygallery2spamworks like a charmnewbcrondhmanuallycontrol panelphpmyadmininterface