I just made the test to be sure: using Wants= does not prevent MySQL to start event if the system never reaches “time-sync.target”.
I added an ntpdate.service:
# /etc/systemd/system/ntpdate.service [Unit] Description=Force synchronisation of time ConditionPathExists=/etc/default/ntpdate DefaultDependencies=no Conflicts=shutdown.target After=network-online.target Before=time-sync.target shutdown.target Wants=network-online.target time-sync.target
[Service] Type=oneshot Environment="NTPSERVERS=pool.ntp.org" EnvironmentFile=/etc/default/ntpdate ExecStart=/usr/sbin/ntpdate -v $NTPSERVERS RemainAfterExit=yes
[Install] WantedBy=sysinit.target
And an override for MySQL:
# /etc/systemd/system/mysql.service.d/override.conf [Unit] After=network-online.target time-sync.target Wants=network-online.target time-sync.target
ntpdate.service is failed:
systemctl status ntpdate.service ● ntpdate.service - Force synchronisation of time Loaded: loaded (/etc/systemd/system/ntpdate.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2018-10-15 16:51:25 CEST; 40s ago Process: 1129 ExecStart=/usr/sbin/ntpdate -v $NTPSERVERS (code=exited, status=1/FAILURE) Main PID: 1129 (code=exited, status=1/FAILURE)
But MySQL is started:
systemctl status mysql.service ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/mysql.service.d └─override.conf Active: active (running) since Mon 2018-10-15 16:51:27 CEST; 3min 17s ago Process: 1600 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS) Process: 1550 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 1602 (mysqld) Tasks: 30 (limit: 4915) CGroup: /system.slice/mysql.service └─1602 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Regards.
I just made the test to be sure: using Wants= does not prevent MySQL to start event if the system never reaches “time-sync.target”.
I added an ntpdate.service:
# /etc/systemd/ system/ ntpdate. service Exists= /etc/default/ ntpdate encies= no shutdown. target network- online. target time-sync. target shutdown.target network- online. target time-sync.target
[Unit]
Description=Force synchronisation of time
ConditionPath
DefaultDepend
Conflicts=
After=
Before=
Wants=
[Service] "NTPSERVERS= pool.ntp. org" le=/etc/ default/ ntpdate /usr/sbin/ ntpdate -v $NTPSERVERS it=yes
Type=oneshot
Environment=
EnvironmentFi
ExecStart=
RemainAfterEx
[Install] sysinit. target
WantedBy=
And an override for MySQL:
# /etc/systemd/ system/ mysql.service. d/override. conf network- online. target time-sync.target network- online. target time-sync.target
[Unit]
After=
Wants=
ntpdate.service is failed:
systemctl status ntpdate.service system/ ntpdate. service; enabled; vendor preset: enabled) /usr/sbin/ ntpdate -v $NTPSERVERS (code=exited, status=1/FAILURE)
● ntpdate.service - Force synchronisation of time
Loaded: loaded (/etc/systemd/
Active: failed (Result: exit-code) since Mon 2018-10-15 16:51:25 CEST; 40s ago
Process: 1129 ExecStart=
Main PID: 1129 (code=exited, status=1/FAILURE)
But MySQL is started:
systemctl status mysql.service system/ mysql.service; enabled; vendor preset: enabled) system/ mysql.service. d
└ ─override. conf /usr/sbin/ mysqld --daemonize --pid-file= /run/mysqld/ mysqld. pid (code=exited, status=0/SUCCESS) /usr/share/ mysql/mysql- systemd- start pre (code=exited, status=0/SUCCESS) slice/mysql. service /run/mysqld/ mysqld. pid
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/
Drop-In: /etc/systemd/
Active: active (running) since Mon 2018-10-15 16:51:27 CEST; 3min 17s ago
Process: 1600 ExecStart=
Process: 1550 ExecStartPre=
Main PID: 1602 (mysqld)
Tasks: 30 (limit: 4915)
CGroup: /system.
└─1602 /usr/sbin/mysqld --daemonize --pid-file=
Regards.