hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Cron Job to FLUSH QUERY CACHE
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Cron Job to FLUSH QUERY CACHE

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 04-25-2011, 08:05 AM
zahirw zahirw is offline
Aspiring Evangelist
 
Join Date: Mar 2011
Posts: 393

Cron Job to FLUSH QUERY CACHE


My query cache is set quite high but it gets fragmented quite fast. I'd like to routinely flush the cache every 2 hours.

I ran this command in shell logged in as root however, it just gave me the list of mysql options instead.

mysql -u username -ppassword databasename "FLUSH QUERY CACHE"

What am I doing wrong? I'd like to save this as a shell script and run it via cron.

Reply With Quote


Sponsored Links
  #2  
Old 04-25-2011, 08:37 AM
iTom iTom is offline
Web Hosting Master
 
Join Date: Apr 2007
Posts: 3,481
Cache is good and there to help so you should be flushing it.

If it using too much RAM simply change your MySQL configuration to reduce the amount of RAM allocated to cache.

That way MySQL will keep it's self in check, without cron's etc...

Reply With Quote
  #3  
Old 04-25-2011, 09:15 AM
zahirw zahirw is offline
Aspiring Evangelist
 
Join Date: Mar 2011
Posts: 393
Hey Tom
I think you misunderstood me. We are using query cache and want to continue doing so. Once the cache fills up though, it starts fragmenting. To avoid that, we'd like to flush it say every 6 hours via cron

Reply With Quote
Sponsored Links
  #4  
Old 04-25-2011, 07:42 PM
nafirici nafirici is offline
Junior Guru Wannabe
 
Join Date: Mar 2011
Posts: 42
I think you would need to use -e:
mysql -u username -ppassword databasename -e "FLUSH QUERY CACHE"

__________________
Nafirici | WI Real Estate

Reply With Quote
  #5  
Old 04-25-2011, 08:14 PM
Crothers Crothers is online now
Web Hosting Master
 
Join Date: Apr 2008
Location: United States, MI
Posts: 555
Quote:
Originally Posted by zahirw View Post
Hey Tom
I think you misunderstood me. We are using query cache and want to continue doing so. Once the cache fills up though, it starts fragmenting. To avoid that, we'd like to flush it say every 6 hours via cron
I do believe that bug is for older versions of MySQL, 5.5 does not have that problem. You're only going to degrade performance with constant flushing.

__________________
Steven Crothers
No BS cloud engineer and Red Hat architect.

Reply With Quote
  #6  
Old 04-26-2011, 03:15 AM
zahirw zahirw is offline
Aspiring Evangelist
 
Join Date: Mar 2011
Posts: 393
Quote:
Originally Posted by nafirici View Post
I think you would need to use -e:
mysql -u username -ppassword databasename -e "FLUSH QUERY CACHE"
Doesn't work...

Reply With Quote
  #7  
Old 04-26-2011, 03:28 AM
GGWH-James GGWH-James is offline
--. --. .-- ....
 
Join Date: Oct 2010
Location: ON, Canada
Posts: 960
'FLUSH QUERY CACHE' doesn't actually remove any queries form the cache, it defragments it. However, 'RESET QUERY CACHE' will remove all query results from the query cache.

__________________
GG Web Hosting
Backup, Digital (SSL) Certificates, Domains, Hosting, Privacy Policy, Software
S/W: Peel Ads, Softaculous, WHMCS Addons (Abuse Mon., Affiliate Peel Ads, Client Stat., Ord. Prevention, Ord. Stat., Softaculous NOC, Sys. Cleanup)
Authorized Reseller Program


Reply With Quote
  #8  
Old 04-26-2011, 03:34 AM
zahirw zahirw is offline
Aspiring Evangelist
 
Join Date: Mar 2011
Posts: 393
Yes, how do I execute the flush query cache query in shell

Reply With Quote
  #9  
Old 04-26-2011, 03:47 AM
GGWH-James GGWH-James is offline
--. --. .-- ....
 
Join Date: Oct 2010
Location: ON, Canada
Posts: 960
Quote:
Originally Posted by zahirw View Post
Yes, how do I execute the flush query cache query in shell
It should be something like this:
Code:
mysql -u {username} -p{password} -e "FLUSH QUERY CACHE"

__________________
GG Web Hosting
Backup, Digital (SSL) Certificates, Domains, Hosting, Privacy Policy, Software
S/W: Peel Ads, Softaculous, WHMCS Addons (Abuse Mon., Affiliate Peel Ads, Client Stat., Ord. Prevention, Ord. Stat., Softaculous NOC, Sys. Cleanup)
Authorized Reseller Program


Reply With Quote
  #10  
Old 04-26-2011, 03:54 AM
zahirw zahirw is offline
Aspiring Evangelist
 
Join Date: Mar 2011
Posts: 393
Didn't work

Reply With Quote
  #11  
Old 04-26-2011, 03:55 AM
GGWH-James GGWH-James is offline
--. --. .-- ....
 
Join Date: Oct 2010
Location: ON, Canada
Posts: 960
Quote:
Originally Posted by zahirw View Post
Didn't work
What I gave you is the correct command line to run the query; unless you need to connect to specify a hostname that is. We run that on a few of our servers every several hours. Does the user that you're passing have the proper permissions to perform that? Do you receive an error?

__________________
GG Web Hosting
Backup, Digital (SSL) Certificates, Domains, Hosting, Privacy Policy, Software
S/W: Peel Ads, Softaculous, WHMCS Addons (Abuse Mon., Affiliate Peel Ads, Client Stat., Ord. Prevention, Ord. Stat., Softaculous NOC, Sys. Cleanup)
Authorized Reseller Program



Last edited by GGWH-James; 04-26-2011 at 04:02 AM.
Reply With Quote
  #12  
Old 04-26-2011, 12:26 PM
nafirici nafirici is offline
Junior Guru Wannabe
 
Join Date: Mar 2011
Posts: 42
Quote:
Originally Posted by zahirw View Post
Doesn't work...
I've also tested this and worked fine for me. Do you have the correct permissions? Is there some sort of an error that you're getting? I would also recommend using RESET QUERY CACHE because GGWH-James is correct, FLUSH QUERY CACHE doesn't remove any queries from the cache and RESET does.

__________________
Nafirici | WI Real Estate

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
query cache denied? elfz Hosting Security and Technology 5 04-14-2010 06:52 AM
cron to flush ip from csf deny list except those marked as do not delete sharmaine1111 Hosting Security and Technology 6 12-05-2009 11:05 PM
setting up crontab flush query cache? acctman Programming Discussion 7 10-07-2009 06:40 PM
mysql: schedule flush query cache hpham Hosting Security and Technology 1 12-05-2007 10:45 PM
Flush Cache on CentOS MziB Hosting Security and Technology 2 06-15-2007 03:59 PM

Related posts from TheWhir.com
Title Type Date Posted
Jelastic Launches Version 1.9.1 of Java and PHP Hosting Platform Web Hosting News 2013-05-21 09:39:09
Certified Hosting Deploys Varnish HTTP Caching for Faster Hosting Services Web Hosting News 2012-02-28 14:10:30
Thousands of Sites Mislabeled Phishers After OpenDNS Blocks Google Hosted Scripts Web Hosting News 2012-01-06 15:37:40
Web Host Amazon Web Services Launches ElastiCache Service Web Hosting News 2011-08-23 17:53:00
WordPress Forces Password Reset After Suspicious Activity on Plugins Detected Web Hosting News 2011-06-22 14:56:47


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?