I have a very simple script that basically runs a command and then emails the report to a user:
#!/bin/bash
FROMDATE=`date -d "last week 13:00 " '+%Y-%m-%d'`
TODATE=`date '+%Y-%m-%d'`
SLOWLOG='/var/log/mysql/slow-queries.log'
REPORT='/home/user/slow.log.'$TODATE
PTQUERY='/usr/bin/pt-query-digest'
SUBJECT="Slow Query Report -- $TODATE"
EMAIL="[email protected]"
$PTQUERY --since=\'$FROMDATE\' --until=\'$TODATE\' $SLOWLOG > $REPORT
/usr/bin/mutt -s "$SUBJECT" "$EMAIL" < $REPORT
Everything works perfect when I run this manually (below)
/usr/bin/pt-query-digest --since='2015-10-21' --until='2015-10-28' /var/log/mysql/slow-queries.log > /home/user/slow.log
And if I echo the line in the script:
/usr/bin/pt-query-digest --since='2015-10-21' --until='2015-10-28' /var/log/mysql/slow-queries.log
When I run the script I get an error
Invalid --since value at /usr/bin/pt-query-digest line 13562.
So it looks like it could be something with the single quotes? I'm not sure. Any help would be greatly appreciated.