Systemd ExecStop run immediately after ExecStart
I have the following file in /etc/systemd/system/mytest.service
[Unit]
Description=My Test Service
After=network.target
[Service]
Type=forking
User=mytestuser
Group=mytestuser
WorkingDirectory=/opt/mytest
ExecStart=/bin/echo "My Test Start!"
ExecStop=/bin/echo "My Test Stop!"
ExecReload=/bin/echo "My Test Restart!"
[Install]
WantedBy=multi-user.target
After running systemctl daemon-reload
and systemctl start mytest
the following output can be seen from journalctl -xe
Jun 29 09:44:57 localhost.localdomain systemd[1]: Starting My Test Service...
-- Subject: Unit mytest.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mytest.service has begun starting up.
Jun 29 09:44:57 localhost.localdomain echo[4370]: My Test Start!
Jun 29 09:44:57 localhost.localdomain echo[4372]: My Test Stop!
Jun 29 09:44:57 localhost.localdomain polkitd[619]: Unregistered Authentication Agent for unix-process:4364:694445 (system bus name :1.149, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_GB.UTF-8) (disconnected from
Jun 29 09:44:57 localhost.localdomain systemd[1]: Started My Test Service.
-- Subject: Unit mytest.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mytest.service has finished starting up.
--
-- The start-up result is done.
This shows the ExecStart command running, immediately followed by the ExecStop, why is this happening? Is there something missing from my .service file?
Thanks
linux systemd centos-7
add a comment |
I have the following file in /etc/systemd/system/mytest.service
[Unit]
Description=My Test Service
After=network.target
[Service]
Type=forking
User=mytestuser
Group=mytestuser
WorkingDirectory=/opt/mytest
ExecStart=/bin/echo "My Test Start!"
ExecStop=/bin/echo "My Test Stop!"
ExecReload=/bin/echo "My Test Restart!"
[Install]
WantedBy=multi-user.target
After running systemctl daemon-reload
and systemctl start mytest
the following output can be seen from journalctl -xe
Jun 29 09:44:57 localhost.localdomain systemd[1]: Starting My Test Service...
-- Subject: Unit mytest.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mytest.service has begun starting up.
Jun 29 09:44:57 localhost.localdomain echo[4370]: My Test Start!
Jun 29 09:44:57 localhost.localdomain echo[4372]: My Test Stop!
Jun 29 09:44:57 localhost.localdomain polkitd[619]: Unregistered Authentication Agent for unix-process:4364:694445 (system bus name :1.149, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_GB.UTF-8) (disconnected from
Jun 29 09:44:57 localhost.localdomain systemd[1]: Started My Test Service.
-- Subject: Unit mytest.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mytest.service has finished starting up.
--
-- The start-up result is done.
This shows the ExecStart command running, immediately followed by the ExecStop, why is this happening? Is there something missing from my .service file?
Thanks
linux systemd centos-7
add a comment |
I have the following file in /etc/systemd/system/mytest.service
[Unit]
Description=My Test Service
After=network.target
[Service]
Type=forking
User=mytestuser
Group=mytestuser
WorkingDirectory=/opt/mytest
ExecStart=/bin/echo "My Test Start!"
ExecStop=/bin/echo "My Test Stop!"
ExecReload=/bin/echo "My Test Restart!"
[Install]
WantedBy=multi-user.target
After running systemctl daemon-reload
and systemctl start mytest
the following output can be seen from journalctl -xe
Jun 29 09:44:57 localhost.localdomain systemd[1]: Starting My Test Service...
-- Subject: Unit mytest.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mytest.service has begun starting up.
Jun 29 09:44:57 localhost.localdomain echo[4370]: My Test Start!
Jun 29 09:44:57 localhost.localdomain echo[4372]: My Test Stop!
Jun 29 09:44:57 localhost.localdomain polkitd[619]: Unregistered Authentication Agent for unix-process:4364:694445 (system bus name :1.149, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_GB.UTF-8) (disconnected from
Jun 29 09:44:57 localhost.localdomain systemd[1]: Started My Test Service.
-- Subject: Unit mytest.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mytest.service has finished starting up.
--
-- The start-up result is done.
This shows the ExecStart command running, immediately followed by the ExecStop, why is this happening? Is there something missing from my .service file?
Thanks
linux systemd centos-7
I have the following file in /etc/systemd/system/mytest.service
[Unit]
Description=My Test Service
After=network.target
[Service]
Type=forking
User=mytestuser
Group=mytestuser
WorkingDirectory=/opt/mytest
ExecStart=/bin/echo "My Test Start!"
ExecStop=/bin/echo "My Test Stop!"
ExecReload=/bin/echo "My Test Restart!"
[Install]
WantedBy=multi-user.target
After running systemctl daemon-reload
and systemctl start mytest
the following output can be seen from journalctl -xe
Jun 29 09:44:57 localhost.localdomain systemd[1]: Starting My Test Service...
-- Subject: Unit mytest.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mytest.service has begun starting up.
Jun 29 09:44:57 localhost.localdomain echo[4370]: My Test Start!
Jun 29 09:44:57 localhost.localdomain echo[4372]: My Test Stop!
Jun 29 09:44:57 localhost.localdomain polkitd[619]: Unregistered Authentication Agent for unix-process:4364:694445 (system bus name :1.149, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_GB.UTF-8) (disconnected from
Jun 29 09:44:57 localhost.localdomain systemd[1]: Started My Test Service.
-- Subject: Unit mytest.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mytest.service has finished starting up.
--
-- The start-up result is done.
This shows the ExecStart command running, immediately followed by the ExecStop, why is this happening? Is there something missing from my .service file?
Thanks
linux systemd centos-7
linux systemd centos-7
edited Jun 29 '17 at 9:03
Jem Tucker
asked Jun 29 '17 at 8:51
Jem TuckerJem Tucker
1085
1085
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The problem is that echo
isn't forking - no child processes are left behind. What you need is a oneshot
service, with RemainAfterExit=true
. If you just change it to oneshot
, you'll get the exact same behavior. The RemainAfterExit
part tells it that even after the ExecStart
exits, the service should still be considered running, so it should not run the ExecStop
(s).
add a comment |
You are using
Type=oneshot
use
Type=forking
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1223957%2fsystemd-execstop-run-immediately-after-execstart%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is that echo
isn't forking - no child processes are left behind. What you need is a oneshot
service, with RemainAfterExit=true
. If you just change it to oneshot
, you'll get the exact same behavior. The RemainAfterExit
part tells it that even after the ExecStart
exits, the service should still be considered running, so it should not run the ExecStop
(s).
add a comment |
The problem is that echo
isn't forking - no child processes are left behind. What you need is a oneshot
service, with RemainAfterExit=true
. If you just change it to oneshot
, you'll get the exact same behavior. The RemainAfterExit
part tells it that even after the ExecStart
exits, the service should still be considered running, so it should not run the ExecStop
(s).
add a comment |
The problem is that echo
isn't forking - no child processes are left behind. What you need is a oneshot
service, with RemainAfterExit=true
. If you just change it to oneshot
, you'll get the exact same behavior. The RemainAfterExit
part tells it that even after the ExecStart
exits, the service should still be considered running, so it should not run the ExecStop
(s).
The problem is that echo
isn't forking - no child processes are left behind. What you need is a oneshot
service, with RemainAfterExit=true
. If you just change it to oneshot
, you'll get the exact same behavior. The RemainAfterExit
part tells it that even after the ExecStart
exits, the service should still be considered running, so it should not run the ExecStop
(s).
answered Jan 22 '18 at 14:58
Duncan X SimpsonDuncan X Simpson
1,105823
1,105823
add a comment |
add a comment |
You are using
Type=oneshot
use
Type=forking
add a comment |
You are using
Type=oneshot
use
Type=forking
add a comment |
You are using
Type=oneshot
use
Type=forking
You are using
Type=oneshot
use
Type=forking
answered Jan 1 at 10:39
bebbobebbo
171127
171127
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1223957%2fsystemd-execstop-run-immediately-after-execstart%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown