Command Line for SQL cron job


#1

I am trying to set up a cron job to delete tracking info in two of mysql tables, but I having trouble finding the command line. I have tried entering the commands below in the crob job area, but there do not to work - However they do work in Run SQL query in phpmyadmin. Below are the 2 commands I wish to run. Could anybody tell what other code i should ad.

DELETE FROM vtp_bnr_tracking WHERE action_date < DATE_SUB(CURDATE(),INTERVAL 14 DAY)

DELETE FROM vtp_text_tracking WHERE action_date < DATE_SUB(CURDATE(),INTERVAL 14 DAY)


#2

Here’s the typical format for a SQL command:

mysql -h mysql.example.com -u username -ppassword newdbname < outfile.sql

The “outfile.sql” file needs to start with a USE statement, such as USE myfile_db;
And your commands also need to be followed by semicolons.

You also very well may need to lock and unlock tables while you work on them, but I’m not a DBA.

-Scott