0

I'm trying to set up in a Redhat server, 2 services that start a database at startup, and stop it at shutdown, so I have put 2 files under /etc/systemd/system as follows:

shutdown.service:

[Unit]
Description=Shutdown database at shutdown
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target

[Service]
Type=oneshot
ExecStart=/usr/DBA/shutdown.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

startup service:

[Unit]
Description=Start   database at startup after network becomes reachable
After=default.target

[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/usr/DBA/startup.sh
TimeoutStartSec=0

[Install]
WantedBy=default.target

then I did these commands:

sudo systemctl daemon-reload
sudo systemctl enable startup.service
sudo systemctl enable shutdown.service
sudo systemctl start startup.service
sudo systemctl start shutdown.service

then when I look at the status, they work fine and show active and running. I then reboot the server, and I check again the status but I get this:

[ec2-user@ip-10-193-117-56 system]$ sudo systemctl status shutdown.service
Unit shutdown.service could not be found.
[ec2-user@ip-10-193-117-56 system]$ sudo systemctl status startup.service
Unit startup.service could not be found.
[ec2-user@ip-10-193-117-56 system]$

So I don't understand, what is the issue. Why the services aren't being found after rebooting the server ? they are supposed to be enabled and started once, then they should start automatically.

Any idea ?

Here are both services inside the folder:

cd /etc/systemd/system
ls -l
-rw-rw-r--. 1 root root  246 Feb 22 16:02  startup.service
-rw-rw-r--. 1 root root  255 Feb 22 16:02  shutdown.service
Souad
  • 236
  • 3
  • 4
  • 14

1 Answers1

0

The answer to this issue is to disable SELinux feature by doing the following ( permanent disabling) :

vi /etc/sysconfig/selinux

Then change the directive SELinux=enforcing to SELinux=disabled

Reboot then : sestatus, it should now show it is disabled.

Souad
  • 236
  • 3
  • 4
  • 14