Question

Mysql Crash only in the night Wordpress

Posted April 15, 2016 2.9k views
Ubuntu MySQL Apache

hello i have 2 GB droplet with 30 GB with 4GB swap space, xmlrpc disable on all my wordpres sites but every night mysql stop working and i dont thing its about out of memory error, please see graph image here: http://i.imgur.com/UAXRumD.png, seems to be something different.
thanks for any help

4 comments
  • looks like there is some internal process that is executing at 4:35am or so. I would say that is either a cronjob, some other scheduled process with wordpress (perhaps a plugin, if not wordpress itself) or possibly mysql although I am not aware of any built-in scheduled mysql jobs by default.

    if i had to rank the list of suspects that I have above, i would think that the most likely ones would possibly by a wordpress plugin, followed by a cronjob.

  • i’ll try disable cron directly from wp-config

  • What do you see for the output of these commands:

    sudo grep Out /var/log/syslog
    
    sudo grep Out /var/log/syslog.1
    
    sudo tail /var/log/mysql/error.log
    
  • by sudo grep Out /var/log/syslog.1

    Apr 22 07:15:17 host3 kernel: [534265.860809] Out of memory: Kill process 3843 ( mysqld) score 49 or sacrifice child
    Apr 22 07:15:44 host3 kernel: [534292.905158] Out of memory: Kill process 20271 (mysqld) score 31 or sacrifice child
    Apr 22 07:15:52 host3 kernel: [534301.169101] Out of memory: Kill process 19898 (apache2) score 21 or sacrifice child
    Apr 22 07:15:55 host3 kernel: [534303.816758] Out of memory: Kill process 19873 (apache2) score 21 or sacrifice child
    Apr 22 07:16:17 host3 kernel: [534325.853745] Out of memory: Kill process 21435 (mysqld) score 26 or sacrifice child
    Apr 22 07:16:27 host3 kernel: [534335.557368] Out of memory: Kill process 20032 (apache2) score 21 or sacrifice child
    Apr 22 07:16:43 host3 kernel: [534351.650379] Out of memory: Kill process 22609 (mysqld) score 26 or sacrifice child
    Apr 22 07:16:45 host3 kernel: [534353.764823] Out of memory: Kill process 19959 (apache2) score 20 or sacrifice child
    Apr 22 07:17:03 host3 kernel: [534372.093176] Out of memory: Kill process 23759 (mysqld) score 23 or sacrifice child
    Apr 22 07:17:05 host3 kernel: [534373.345797] Out of memory: Kill process 20010 (apache2) score 20 or sacrifice child
    Apr 22 07:17:17 host3 kernel: [534385.844850] Out of memory: Kill process 24910 (mysqld) score 25 or sacrifice child
    Apr 22 07:17:21 host3 kernel: [534390.031834] Out of memory: Kill process 20053 (apache2) score 20 or sacrifice child
    Apr 22 07:17:37 host3 kernel: [534405.716551] Out of memory: Kill process 26042 (mysqld) score 21 or sacrifice child
    Apr 22 07:17:51 host3 kernel: [534419.793204] Out of memory: Kill process 27192 (mysqld) score 23 or sacrifice child
    Apr 22 07:18:02 host3 kernel: [534430.654578] Out of memory: Kill process 20060 (apache2) score 20 or sacrifice child
    Apr 22 07:18:07 host3 kernel: [534435.805218] Out of memory: Kill process 20077 (apache2) score 20 or sacrifice child
    Apr 22 07:18:21 host3 kernel: [534449.281046] Out of memory: Kill process 20054 (apache2) score 20 or sacrifice child
    Apr 22 07:18:51 host3 kernel: [534479.774352] Out of memory: Kill process 20059 (apache2) score 20 or sacrifice child
    Apr 22 07:19:21 host3 kernel: [534509.247203] Out of memory: Kill process 20073 (apache2) score 20 or sacrifice child

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

Based on the error messages in the log files, it appears that the Apache and MySQL processes are being killed due to the server running out of memory. As @SphericalCow suggested, it’s most likely a scheduled task (a Wordpress plug-in, cronjob, etc.) that is being run at that specific time and using up too many resources, taking up a lot of memory.

To those who are running into this issue and landing on this page via search, I would recommend looking at your plug-ins and cron jobs and seeing if there are any tasks that might be causing this issue. The command crontab -l will show you the configured cron jobs for the current user. Take a look at this tutorial for some info on the syntax: https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-on-a-vps

by Shaun Lewis
Learn how to use cron to automate tasks on a VPS.
Submit an Answer