0

friends!

I need a mechanism to verify if the linux virtual private server is utilizing systemctl or service.

The systemd application is installed on all of them.

Current Code.

if pgrep systemd-journal; then
    systemctl restart unbound
else
    service unbound restart
fi

1 Answers1

0
ps --no-headers -o comm 1

This returns either systemd or init and appears reliable across Linux distributions and releases.