Hi,
I created another service named 5PM. The purpose of the service is to run a test script that checks for processes, e.g. asm_pmon+ASM, etc. To accomplish this however I want to make sure 5PM starts after oracle-ohasd has finished.
From what I understand, After=oracle-ohasd.service makes sure the service is started after the specified service, but not necessarily after the specified service has completed.
From the documentation at https://www.freedesktop.org/software/systemd/man/systemd.unit.html
After=
is the inverse of Before=
, i.e. while After=
ensures that the configured unit is started after the listed unit finished starting up, Before=
ensures the opposite, that the configured unit is fully started up before the listed unit is started.
I wonder if this is working as advertised, but how do I make sure 5PM starts after oracle-ohasd finished?
# journalctl -u 5PM
Apr 19 03:33:26 localhost.localdomain systemd[1]: Stopping Troubleshooting systemd...
Apr 19 03:33:26 localhost.localdomain test.sh[6263]: grid 5893 1 0 03:30 ? 00:00:00 asm_pmon_+ASM
Apr 19 03:33:26 localhost.localdomain test.sh[6263]: root 6279 6263 0 03:33 ? 00:00:00 grep asm_pmon
Apr 19 03:33:26 localhost.localdomain systemd[1]: Stopped Troubleshooting systemd.
# journalctl -u oracle-ohasd
Apr 19 03:33:26 localhost.localdomain systemd[1]: Stopping Oracle High Availability Services...
Apr 19 03:33:27 localhost.localdomain root[6374]: Starting execution of Oracle Clusterware init.ohasd
etc....
Apr 19 03:33:40 localhost.localdomain init.ohasd[6303]: CRS-4133: Oracle High Availability Services has been stopped.
Apr 19 03:33:40 localhost.localdomain systemd[1]: Stopped Oracle High Availability Services.
# cat /etc/systemd/system/5PM.service
[Unit]
Description=Troubleshooting systemd
# After=iscsi-shutdown.service iscsi.service iscsid.service
After=oracle-ohasd.service
DefaultDependencies=no
Conflicts=shutdown.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=-/usr/bin/true
#ExecStop=-/sbin/iscsiadm -m node -u
ExecStop=-/test.sh
What am I missing here?
Thanks!
Update:
This has become a long and confusing thread and probably isn't very useful, but to sum up, using "Before=" provided the function I was looking for. The reason why it did not seem to work as anticipated may have been because I forgot to use systemctl daemon-reload or mixed up the results.
Avi was correct that "Before=" is inverted at system shutdown. "Wants=" or "Requires=" do not influence the starting or stopping order, but define service dependencies.
FWIW:
Creating my own u01.mount service would have been another option, but since stopping the OHASD service (oracle-ohasd) keeps frequently failing (19.3), more programming to successfully unmount /u01 is necessary.
The system automatically creates .mount services for entries in /etc/fstab, but according to the documentation /etc/fstab is the preferred standard and also required for compatibility with other tools. (https://www.freedesktop.org/software/systemd/man/systemd.mount.html )
Mount units may either be configured via unit files, or via /etc/fstab
(see fstab(5) for details). Mounts listed in /etc/fstab
will be converted into native units dynamically at boot and when the configuration of the system manager is reloaded. In general, configuring mount points through /etc/fstab
is the preferred approach.
If a mount point is configured in both /etc/fstab
and a unit file that is stored below /usr
, the former will take precedence. If the unit file is stored below /etc
, it will take precedence. This means: native unit files take precedence over traditional configuration files, but this is superseded by the rule that configuration in /etc
will always take precedence over configuration in /usr
.