Starting Daily apt upgrade and clean activities stopping mysql service

18,796

Solution 1

I'm not sure it's possible to stop mysql from being killed by the update process. I've had the same problem and I disabled unattended updates entirely so that I can do them on my own schedule (after also testing them in a qa environment). To disable the automatic daily updates entirely:

sudo apt-get remove unattended-upgrades
sudo systemctl stop apt-daily.timer
sudo systemctl disable apt-daily.timer
sudo systemctl disable apt-daily.service
sudo systemctl daemon-reload

Solution 2

I've had this issue occur as well. Mysql stopped for no apparent reason. Upon further investigation of the syslog I found this

systemd[1]: Starting Daily apt upgrade and clean activities...
systemd[1]: Stopping MySQL Community Server...
systemd[1]: Stopped MySQL Community Server.

The way to fix this problem was to use apt-mark hold to stop updates to all packages that have mysql in their name, this way mysql will never shut down for updates. This will, however, stop automatic updates.

Another way to solve this was to make sure the systemd unit for mysql is enabled. In that case it would reboot right back up after the update, so no need to blacklist the package with apt-mark hold.

Share:
18,796

Related videos on Youtube

Jatin Seth
Author by

Jatin Seth

Updated on September 18, 2022

Comments

  • Jatin Seth
    Jatin Seth over 1 year

    I am running Ubuntu(16.04) with MySQL(5.7). Daily when Ubuntu job(Daily apt upgrade and clean activities) is running, it's stopping MySQL service and I will have to manually restart it. My syslog entries are given below:

    May 17 06:53:19 campaygn-production systemd[1]: Starting Daily apt upgrade and clean activities...
    May 17 06:53:27 campaygn-production systemd[1]: Reloading.
    May 17 06:53:27 campaygn-production systemd[1]: Started ACPI event daemon.
    May 17 06:53:27 campaygn-production systemd[1]: Stopping MySQL Community Server...
    May 17 06:53:36 campaygn-production systemd[1]: Stopped MySQL Community Server.
    

    How to stop ubuntu to shutdown mysql every-time ?

    • damadam
      damadam almost 6 years
      I don't think you should see the problem like "stopping the shutdown of your mysql servce" but more like "restart automatically your mysql service after daily upgrade"
    • Jatin Seth
      Jatin Seth almost 6 years
      yeah, that's what I am looking for, I am not able to find a way to automatically restart MYSQL when it's shutdown by daily upgrade, cuz daily upgrade don't run at a particular time.
    • damadam
      damadam almost 6 years
      can't you add sudo service mysql restart at the end of your script which launch the daily upgrade (if the mysql service is mysql)?
    • Anish
      Anish over 5 years
      Does /etc/mysql/FROZEN exist?
    • Jatin Seth
      Jatin Seth over 5 years
      @RobieBasak - no, this file does not exist.
  • Jatin Seth
    Jatin Seth almost 6 years
    Oh !, I have updated the question, it is, can I stop this behaviour without disable this automatic job ?
  • Ingus
    Ingus over 4 years
    "Another way to solve this was to make sure the systemd unit for mysql is enabled" How to check that? apt-mark hold mysql-server seems did not helped :(
  • HelloWorld
    HelloWorld about 4 years
    @Ingus I think checking can be done with systemctl is-enabled mysql, and in case it is disabled you can run systemctl enable mysql to enable it. This won't stop the updates from shutting down mysql, but will hopefully make mysql start back up again. The case I described is for mysql getting shut down by automatic updates, this shouldn't happen often. What exactly happened in your case?
  • HelloWorld
    HelloWorld about 4 years
    @Ignus apt-mark hold didn't help? You mean you had mysql shut down again the next time ubuntu automatically run updates?
  • Ingus
    Ingus about 4 years
    ` apt-mark ` did the trick after i used correct package :)