0

My problem is that this:

mysql -u root -pmypassword -D cache -e "DELETE FROM cache WHERE job IN('SET', 'UO', 'AV');"

MySQL query doesn't run with the cronjob. I am sure that the cronjob starts itself because rest of the code (mysqldump) is running.

#!/usr/local/bin/bash

mysql -u mysql-u1494 -pmy-password -D cache -e "DELETE FROM cache WHERE job IN('SET', 'UO', 'AV');"

/usr/local/bin/mysqldump --skip-lock-tables --ignore-table=log.log --user="mysql-u1494" --password="my-password" names > dump.sql

When I run this command manually inside of the terminal it works fine. So the question is, why doesn't this query run?

1
  • Possible authentication problem, my first wild guess. Have you looked at the MySQL log(s) for other clues? Commented Jul 21, 2013 at 1:34

1 Answer 1

1

Probable causes are

  1. because you didn't provide a full path for mysql
  2. your password contains characters that need to be escaped

Try to change

mysql -u mysql-u1494 -pmy-password -D cache -e "DELETE FROM cache WHERE job IN('SET', 'UO', 'AV');"

to

/usr/local/bin/mysql -u mysql-u1494 -p"my-password" -D cache -e "DELETE FROM cache WHERE job IN('SET', 'UO', 'AV');"
^^^^^^^^^^^^^^                        ^           ^
Sign up to request clarification or add additional context in comments.

1 Comment

Argh. Yes - thats was the problem. Thank you Peter. Will accept the answer within 5 minutes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.