cancel
Showing results for 
Search instead for 
Did you mean: 

systemctl reboot

kknfg
Explorer
0 Kudos

Dear Linux/SAP experts,

When ever we execute the command systemctl reboot - the first step it does is it kills all SAP processes.

Later sapinit services runs to start SAP (from /etc/init.d location).

My requirements are below and tried several options, none worked for it.

Instead of Reboot command killing the SAP processes, I needed to shutdown SAP processes using sapstop command or sapinit stop command thru a service or embedding in to an existing script. Is there any way to accomplish this?

Note: I created new services under /etc/systemd/system or /usr/lib/systemd/system_shutdown or /usr/lib/systemd/system to stop SAP before the reboot command killing the processes and none worked, reason being reboot command already killed the SAP processes before it reaching my service/script.

Any ideas or exeert's suggestions?

Helps will be greatly appreciated.

thanks and best regards,

KK

[Unit] Description=Before Shutting Down

DefaultDependencies=no

RequiresMountsFor=/usr/sap /home /sapmnt /

After=shutdown.target reboot.target network.service

[Service] KillUserProcesses=no

KillMode=none

SendSIGKILL=no

RemainAfterExit=yes

TimeoutStopSec=5min

TimeoutSec=5min

Type=oneshot

ExecStart=/usr/lib/systemd/system-shutdown/NFGsapstop

[Install]

WantedBy=shutdown.target reboot.target multi-user.target network.target

Accepted Solutions (0)

Answers (2)

Answers (2)

dalew
Discoverer

I've been having exactly the same problem a eventually found a solution. Start sapstartsrv outside of the user slice. Processes started by it are then no longer part of the user slice and therefore aren't killed immediately at shutdown.

The way I achieve this it having a system service that runs as the <sid>adm user (User=<sid>adm in the .service file). This service restarts sapstartsrv if it is running, resulting in the process now being part of this system service's cgroup. All processes started by sapstartsrv end up part of the same cgroup.

You can also change all sapstartsrv processes to the system slice with this, though I think it's better to put them somewhere more useful like your own stop/start service:

for pid in $(pidof sapstartsrv); do
  echo $pid > /sys/fs/cgroup/systemd/system.slice/cgroup.procs
done
kknfg
Explorer
0 Kudos

Dear Dale Wilson,

Your approach of echoing the processid to cgroup.procs at system.slice level works fine and expected results achieved .

This echo of processid should be done ahead of time before reboot starts, we manually echoed all SAP processes ids to above cgroup.procs and then we tried reboot command - reboot command stopped SAP processes gracefully using sapinit script without killing any of the processes.

Questions:

1. How to automate the cgroup.procs file at system level with new ids? After reboot now all SAP processes has new proc ids.

2. I do not understand your other option of adding User=<sid>adm in the .service file. Are you talking about /etc/services here?

Where is .service file that you are referring

thanks and best regards,

KK

moti_shakutai
Explorer
0 Kudos

Hi Kannan,

Here is an answer from SAP support for the same issue.

BTW, it did not worked for us.

Please try and publish your results

"with system, the sapinit script (and processes started by it) are placed in user slice. Normally system allows only a 90 seconds for these processes to stop before killing them.

SUSE provides a workaround for such situation: https://www.suse.com/de-de/support/kb/doc/?id=7022671

The KBA is described in the context of HA cluster, but it can be applied in the same way for standalone systems as well. I recommend you to try it first in a test environment."

Thanks

Moti

kknfg
Explorer
0 Kudos

Dear Moti,

We have Red Hat RHEL 7 version and your solution worked for us too. The only question that I have is below

Is the solution a supported solution for RHEL7? Also I need to test this scenario thoroughly, so that no other impacts are seen.

thanks for your suggestions.

KK