The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to delete client's mysql by scheduled time?

Discussion in 'Workarounds and Optimization' started by neorder, Jul 18, 2010.

  1. neorder

    neorder Well-Known Member

    Joined:
    Jun 16, 2003
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    6
    I'm setting up a server for clients to test cpanel, now I'm wondering if there is a script that can be run to clear all the database the client created during their play?
     
  2. madaboutlinux

    madaboutlinux Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    1,052
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    Earth
    When are you looking to schedule the deletion? Everyday, everyhour? BTW, if you will be providing one test cPanel login, all the databases will be created as "username_dbname", this will make it difficult to track down which databases were created recently and are been testing by clients and which are not in use (ofcourse we can delete them according to their creation time) but what criteria are you looking to set for the deletion?
     
  3. neorder

    neorder Well-Known Member

    Joined:
    Jun 16, 2003
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    6
    what about running a script to search /var directory for big size files, I will schedule it to run daily, to search any database that's more than 2M size and delete the database itself.

    the problem is, this doesn't looked like the right way to "drop" a database, so will it affect the integrity of the mysql server?

    PS. I like your blog, I actually started to read it since few month ago, the information in there is very very helpful to me on some occasions.
     
  4. Miraenda

    Miraenda Well-Known Member

    Joined:
    Jul 28, 2004
    Messages:
    242
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Coralville, Iowa USA
    You could try using incrond to check the contents of /var/lib/mysql for modifications, and then have it take action whenever something is changed in /var/lib/mysql for that set user (it can do search patterns or exclusions).

    Unlike a cron, it doesn't base these on time but on a change happening in a directory. There's a recent great tutorial on using it at NixCraft:

    Linux incrond inotify: Monitor Directories For Changes And Take Action

    I think it might be the better option over a cron here because any changes to /var/lib/mysql for that set cPanel user name could be checked by incrond and then those databases cleared in some manner after a time delay when the action occurs (so clearing the database an hour after a table was added to it for example). It's up to you how you want them to be cleared, I'm just pointing out a better option over a cron or script based on time.
     
    #4 Miraenda, Jul 21, 2010
    Last edited: Jul 21, 2010
Loading...
Similar Threads - delete client's mysql
  1. jasoncollege24
    Replies:
    1
    Views:
    234

Share This Page