I have this query that outputs updates older than 7 days from a database. How would I make a script that takes the MySQL statement and puts it into a script to be executed by cron.
echo "select name, reported_at from nodes where reported_at < curdate() -7;" |
mysql dashboard
Sample output:
name reported_at
xadf.edu 2012-03-21 14:39:02
xadf.edu 2012-03-22 15:30:01
adsfsadf.edu 2012-03-14 14:40:02
ekdahlj.edu 2012-03-23 03:40:04
adfasdf.net 2012-03-21 14:42:02
eqrsdr.edu 2012-03-15 14:42:02
qwerwfva.edu 2012-03-13 14:42:03
qerqwer.edu 2012-03-23 14:40:01
adfasde.edu 2012-03-05 17:42:03
bsfdgs.edu 2012-03-23 15:20:01
adfadsf.edu 2012-03-23 14:43:01