Score:0

Unit shutdown.service could not be found

ru flag

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
in flag
Why the shutdown "service"? Why don't you just define shutdown and start in one service unit?
Somar avatar
ru flag
what do you mean ? they are not triggered by the same triggers. that's not the question here.
in flag
You don't need two service definitions to start and stop a service. Both should be handled by the same unit file.
Score:0
ru flag

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.

in flag
Disabling selinux is not a solution. Create a selinux module to allow what you need to do instead.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.