Upstart job running script
Ubuntu 14.04
I have simple upstart job test.conf
:
root@ubuntutest:~# cat /etc/init/test.conf
expect fork
script
/root/test.py
end script
and simple python script /root/test.py
:
root@ubuntutest:~# cat /root/test.py
#!/usr/bin/python
import time
print("Hello, World")
time.sleep(30)
print("Goodbye")
I start test job, ensure that upstart tracks proper PID, wait script's termination, but than upstart doesn't stop tracking non-existing PID. So upstart always shows that the job is running (while actually it is not)
root@ubuntutest:~# initctl status test
test stop/waiting
root@ubuntutest:~# initctl start test
test start/running, process 1859
root@ubuntutest:~# ps aux | grep 1859
root 1859 0.2 0.7 29832 7188 ? S 14:43 0:00 /usr/bin/python /root/test.py
root 1862 0.0 0.2 11760 2156 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# ps aux | grep 1859
root 1864 0.0 0.2 11760 2224 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# initctl status test
test start/running, process 1859
If i delete expect fork
from test job then everything works good (except upstart tracks sh
instead of python
) - i want to understand what's wrong with my code?
The same happens if i use bash script instead of python:
#!/bin/bash
sleep 30
ubuntu-14.04 upstart
add a comment |
Ubuntu 14.04
I have simple upstart job test.conf
:
root@ubuntutest:~# cat /etc/init/test.conf
expect fork
script
/root/test.py
end script
and simple python script /root/test.py
:
root@ubuntutest:~# cat /root/test.py
#!/usr/bin/python
import time
print("Hello, World")
time.sleep(30)
print("Goodbye")
I start test job, ensure that upstart tracks proper PID, wait script's termination, but than upstart doesn't stop tracking non-existing PID. So upstart always shows that the job is running (while actually it is not)
root@ubuntutest:~# initctl status test
test stop/waiting
root@ubuntutest:~# initctl start test
test start/running, process 1859
root@ubuntutest:~# ps aux | grep 1859
root 1859 0.2 0.7 29832 7188 ? S 14:43 0:00 /usr/bin/python /root/test.py
root 1862 0.0 0.2 11760 2156 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# ps aux | grep 1859
root 1864 0.0 0.2 11760 2224 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# initctl status test
test start/running, process 1859
If i delete expect fork
from test job then everything works good (except upstart tracks sh
instead of python
) - i want to understand what's wrong with my code?
The same happens if i use bash script instead of python:
#!/bin/bash
sleep 30
ubuntu-14.04 upstart
add a comment |
Ubuntu 14.04
I have simple upstart job test.conf
:
root@ubuntutest:~# cat /etc/init/test.conf
expect fork
script
/root/test.py
end script
and simple python script /root/test.py
:
root@ubuntutest:~# cat /root/test.py
#!/usr/bin/python
import time
print("Hello, World")
time.sleep(30)
print("Goodbye")
I start test job, ensure that upstart tracks proper PID, wait script's termination, but than upstart doesn't stop tracking non-existing PID. So upstart always shows that the job is running (while actually it is not)
root@ubuntutest:~# initctl status test
test stop/waiting
root@ubuntutest:~# initctl start test
test start/running, process 1859
root@ubuntutest:~# ps aux | grep 1859
root 1859 0.2 0.7 29832 7188 ? S 14:43 0:00 /usr/bin/python /root/test.py
root 1862 0.0 0.2 11760 2156 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# ps aux | grep 1859
root 1864 0.0 0.2 11760 2224 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# initctl status test
test start/running, process 1859
If i delete expect fork
from test job then everything works good (except upstart tracks sh
instead of python
) - i want to understand what's wrong with my code?
The same happens if i use bash script instead of python:
#!/bin/bash
sleep 30
ubuntu-14.04 upstart
Ubuntu 14.04
I have simple upstart job test.conf
:
root@ubuntutest:~# cat /etc/init/test.conf
expect fork
script
/root/test.py
end script
and simple python script /root/test.py
:
root@ubuntutest:~# cat /root/test.py
#!/usr/bin/python
import time
print("Hello, World")
time.sleep(30)
print("Goodbye")
I start test job, ensure that upstart tracks proper PID, wait script's termination, but than upstart doesn't stop tracking non-existing PID. So upstart always shows that the job is running (while actually it is not)
root@ubuntutest:~# initctl status test
test stop/waiting
root@ubuntutest:~# initctl start test
test start/running, process 1859
root@ubuntutest:~# ps aux | grep 1859
root 1859 0.2 0.7 29832 7188 ? S 14:43 0:00 /usr/bin/python /root/test.py
root 1862 0.0 0.2 11760 2156 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# ps aux | grep 1859
root 1864 0.0 0.2 11760 2224 pts/0 S+ 14:43 0:00 grep --color=auto 1859
root@ubuntutest:~# initctl status test
test start/running, process 1859
If i delete expect fork
from test job then everything works good (except upstart tracks sh
instead of python
) - i want to understand what's wrong with my code?
The same happens if i use bash script instead of python:
#!/bin/bash
sleep 30
ubuntu-14.04 upstart
ubuntu-14.04 upstart
asked Nov 16 '18 at 8:19
stepanov.dmitstepanov.dmit
62
62
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Why not simply use the exec
stanza rather than script [...] end script
?
description "my python script"
start on startup
task
exec python
Alternatively you can exec the python program from within the script section:
description "my python script, with extra steps"
start on started dbus
task
script
echo foo >/tmp/bar
exec python myscript.py
end script
As a short answer on why upstart thinks the process is still alive even though it has exited: the shell process is intercepting the signals that upstart would normally receive when your python program exits, and Upstart cannot know that the process has exited without these signals.
Hm...does it mean thatupstart
is not able to track correctly any process that is a child ofsh
?
– stepanov.dmit
Nov 26 '18 at 7:43
correct, upstart is unable to supervise child processes of the shell.
– CameronNemo
Nov 28 '18 at 2:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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%2fstackoverflow.com%2fquestions%2f53333917%2fupstart-job-running-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Why not simply use the exec
stanza rather than script [...] end script
?
description "my python script"
start on startup
task
exec python
Alternatively you can exec the python program from within the script section:
description "my python script, with extra steps"
start on started dbus
task
script
echo foo >/tmp/bar
exec python myscript.py
end script
As a short answer on why upstart thinks the process is still alive even though it has exited: the shell process is intercepting the signals that upstart would normally receive when your python program exits, and Upstart cannot know that the process has exited without these signals.
Hm...does it mean thatupstart
is not able to track correctly any process that is a child ofsh
?
– stepanov.dmit
Nov 26 '18 at 7:43
correct, upstart is unable to supervise child processes of the shell.
– CameronNemo
Nov 28 '18 at 2:13
add a comment |
Why not simply use the exec
stanza rather than script [...] end script
?
description "my python script"
start on startup
task
exec python
Alternatively you can exec the python program from within the script section:
description "my python script, with extra steps"
start on started dbus
task
script
echo foo >/tmp/bar
exec python myscript.py
end script
As a short answer on why upstart thinks the process is still alive even though it has exited: the shell process is intercepting the signals that upstart would normally receive when your python program exits, and Upstart cannot know that the process has exited without these signals.
Hm...does it mean thatupstart
is not able to track correctly any process that is a child ofsh
?
– stepanov.dmit
Nov 26 '18 at 7:43
correct, upstart is unable to supervise child processes of the shell.
– CameronNemo
Nov 28 '18 at 2:13
add a comment |
Why not simply use the exec
stanza rather than script [...] end script
?
description "my python script"
start on startup
task
exec python
Alternatively you can exec the python program from within the script section:
description "my python script, with extra steps"
start on started dbus
task
script
echo foo >/tmp/bar
exec python myscript.py
end script
As a short answer on why upstart thinks the process is still alive even though it has exited: the shell process is intercepting the signals that upstart would normally receive when your python program exits, and Upstart cannot know that the process has exited without these signals.
Why not simply use the exec
stanza rather than script [...] end script
?
description "my python script"
start on startup
task
exec python
Alternatively you can exec the python program from within the script section:
description "my python script, with extra steps"
start on started dbus
task
script
echo foo >/tmp/bar
exec python myscript.py
end script
As a short answer on why upstart thinks the process is still alive even though it has exited: the shell process is intercepting the signals that upstart would normally receive when your python program exits, and Upstart cannot know that the process has exited without these signals.
answered Nov 24 '18 at 2:47
CameronNemoCameronNemo
57425
57425
Hm...does it mean thatupstart
is not able to track correctly any process that is a child ofsh
?
– stepanov.dmit
Nov 26 '18 at 7:43
correct, upstart is unable to supervise child processes of the shell.
– CameronNemo
Nov 28 '18 at 2:13
add a comment |
Hm...does it mean thatupstart
is not able to track correctly any process that is a child ofsh
?
– stepanov.dmit
Nov 26 '18 at 7:43
correct, upstart is unable to supervise child processes of the shell.
– CameronNemo
Nov 28 '18 at 2:13
Hm...does it mean that
upstart
is not able to track correctly any process that is a child of sh
?– stepanov.dmit
Nov 26 '18 at 7:43
Hm...does it mean that
upstart
is not able to track correctly any process that is a child of sh
?– stepanov.dmit
Nov 26 '18 at 7:43
correct, upstart is unable to supervise child processes of the shell.
– CameronNemo
Nov 28 '18 at 2:13
correct, upstart is unable to supervise child processes of the shell.
– CameronNemo
Nov 28 '18 at 2:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f53333917%2fupstart-job-running-script%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