Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom service that I need started after mysql comes online. I am attempting to use systemd/systemctl to start the service at boot. I have set mysqld.service in my custom configuration file. What appears to be the problem is systemctl believes mysql has finished starting and therefore proceeds to start my custom service but custom service fails to the connect to the database, after reviewing the log. Checking the timestamps on the mysql log it shows that my custom service is starting before mysql is ready to start. I have looks around the documentation of systemctl and there does not appear to be any "wait before starting timeout" or "wait until a socket is listening for connections". How can I ensure mysql is ready before my custom service starts?

share|improve this question
add a delay to the start? – soandos Apr 20 '12 at 0:20
Where? systemctl configuration files don't have a sleep – Dan S Apr 20 '12 at 0:37
Apparently, there's a bug in mysql's unit file wherein systemd thinks its started before it actually is. You should file it. To use soandos' workaround, you can add something like ExecStartPre=/bin/sleep 10. – Patches Apr 28 '12 at 15:36

There is an option in systemd.service files, that explicitly checks for the existing of the socket.

In the systemd documentation Lennart Pöttering goes great length to describe that most services don't need the actual deamon started, but just the socket to bind to.

Systemd can create those sockets, and starts mysql on first access! This is one of the main reasons, systemd was created.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.