The following works as expected from the command prompt. But it does not work from cron.
mysqldumpslow <(tail -1000 `mysqladmin variables \
| grep slow_query_log_file | awk '{print $4}'`) \
| mail -s "slow log from `hostname` sorted by time" amar`hostname`@gmail.com \
> /root/slow_succ.txt 2> /root/slow_err.txt
I get the following error:
/bin/sh: -c: line 0: syntax error near unexpected token `('
Do certain characters need to be escaped in cron? Or is it an issue with subshell in cron?
Best Answer
I'll expand on what SvenW said by stating that I would put this command into a script for two reasons:
/root/bin/dump_mysql_tables_and_email_failure_report.sh
. You may not be in an environment with other administrators, but this will serve to remind you what the heck you were thinking a year from now! :)