Skip to main content

FLUSH QUERY CACHE once per day for database

Comments

6 comments

  • User Avatar
    vanessa
    Just add it to the root crontab (/var/spool/cron/root) 0 5 * * * mysql -e 'FLUSH QUERY CACHE'
    Or put the above command in a shell script and call the shell script via cron, which is typically how I would do it. Maybe also check that this is the query you actually want to run: [url=http://dev.mysql.com/doc/refman/5.5/en/flush.html]MySQL :: MySQL 5.5 Reference Manual :: 13.7.6.3 FLUSH Syntax
    0
  • User Avatar
    ASTRAPI
    I got that recommendation from mysqltuner :) So: crontab -e Edit: 0 5 * * * mysql -e 'FLUSH QUERY CACHE' Is this syntax ok to flush the query cache? And that's it? No sql info or anything else for login ? The cache is 256mb is it ok or too big to run this command on it? Thanks
    0
  • User Avatar
    vanessa
    the mysql root credentials are defined in /root/.my.cnf which is why when you type 'mysql' via CLI when logged in as root, you don't have to provide credentials. It should work this way via cron as well unless something is weird with your environment. I don't see an issue running this command periodically.
    0
  • User Avatar
    ASTRAPI
    Ok thanks :) Is this global and can run it as you recommend it or i must select on which database it must run?
    0
  • User Avatar
    vanessa
    It's a global command, just run it as written.
    0
  • User Avatar
    cPanelMichael
    Hello :) I am happy to see this issue has been addressed. I am marking this thread as [Resolved]. Thank you.
    0

Please sign in to leave a comment.