I am trying to set up cron to run the mysqlauditgrep command (its the MySQL 5.6 Utilities package). The mysqlauditgrep command is in bash.

The command I am looking to run is:

mysqlauditgrep --format=GRID /var/lib/mysql/audit.log

This command will make my audit log that has been created by mysql to be viewed in a Grid format. It is not run in the mysql shell.

So I just installed Cron and set up the crontab by setting this:

00 11 * * fri root usr/bin/mysqlauditgrep mysqlauditgrep --format=GRID /var/lib/mysql/audit.log

I did run /sbin/service crond start after I nanoed into the crontab file.

I am unable to see if the action has taken place though.


Your crontab line should be like this:

00 11 * * fri /usr/bin/mysqlauditgrep --format=GRID /var/lib/mysql/audit.log

Type man 5 crontab to check the syntax of crontab file


Your line in cron entry includes root and that's not needed, because when you invoke crontab -e it will start to edit cron as current user e.g root. All cron entries are located under /var/spool/cron/<user> so there you can check entries. Also in /var/log/cron you can check cron log with specific messages for cron jobs. So there you can check if action is taken place by cron of course if your script is ok, also to notice that best way for cron entries is to redirect them to >/dev/null just to avoid some spam if MTA is running, also and the last is to add logging into your script itself so that you can be 100 % sure that everything is went ok.

By default cron uses sh not bash so in cron &> is a shortcut to redirect both stderr and stdout in bash, but that's not case in sh. Solution for this is to add env varibale in crontab SHELL=/bin/bash or in front of the script this bash -c also in crontab line, crontab invokes another shell than your current, so your request to see in the same time is not possible, one of the solutions could be mail agent if you have.

  • ok great! thank you! So I am able to view the log. I was wondering if I can see the command be run in the command line for the time I set or does it have to have an output to .txt file. I would like it run in bash and show up on the screen instead of opening a .txt file – lkalti Jul 17 '14 at 20:50
  • i've updated the answer – klerk Jul 17 '14 at 21:11
  • just add this SHELL=/bin/bash with crontab -e – klerk Jul 17 '14 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.