How do i limit the amount of time a python script runs [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
Kill process with timeout
1 answer
So i use a python scrips that sometimes on some ips it just hangs. I run the script on about 250 ips. With xargs from a sh script
How would i i limit the time of the py script runing. If it hang for more than 30 sec for example to leave/kill ?
I dont want to use time as it is server dependant.
I was thinking more of a python function
linux python
marked as duplicate by Jeff Schaller, Jesse_b, Archemar, Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
May 3 at 18:40
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
Kill process with timeout
1 answer
So i use a python scrips that sometimes on some ips it just hangs. I run the script on about 250 ips. With xargs from a sh script
How would i i limit the time of the py script runing. If it hang for more than 30 sec for example to leave/kill ?
I dont want to use time as it is server dependant.
I was thinking more of a python function
linux python
marked as duplicate by Jeff Schaller, Jesse_b, Archemar, Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
May 3 at 18:40
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Here is a similar question: unix.stackexchange.com/questions/254457/â¦
â dhag
May 3 at 16:53
I want to limit the amount of food I eat, but I donâÂÂt want to monitor my food intake.â What?â If you donâÂÂt want to âÂÂuseâ¯timeâÂÂ,â what is your question?
â Scott
May 3 at 22:20
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Kill process with timeout
1 answer
So i use a python scrips that sometimes on some ips it just hangs. I run the script on about 250 ips. With xargs from a sh script
How would i i limit the time of the py script runing. If it hang for more than 30 sec for example to leave/kill ?
I dont want to use time as it is server dependant.
I was thinking more of a python function
linux python
This question already has an answer here:
Kill process with timeout
1 answer
So i use a python scrips that sometimes on some ips it just hangs. I run the script on about 250 ips. With xargs from a sh script
How would i i limit the time of the py script runing. If it hang for more than 30 sec for example to leave/kill ?
I dont want to use time as it is server dependant.
I was thinking more of a python function
This question already has an answer here:
Kill process with timeout
1 answer
linux python
edited May 3 at 21:33
asked May 3 at 16:51
Killroy2018
346
346
marked as duplicate by Jeff Schaller, Jesse_b, Archemar, Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
May 3 at 18:40
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Jeff Schaller, Jesse_b, Archemar, Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
May 3 at 18:40
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Here is a similar question: unix.stackexchange.com/questions/254457/â¦
â dhag
May 3 at 16:53
I want to limit the amount of food I eat, but I donâÂÂt want to monitor my food intake.â What?â If you donâÂÂt want to âÂÂuseâ¯timeâÂÂ,â what is your question?
â Scott
May 3 at 22:20
add a comment |Â
Here is a similar question: unix.stackexchange.com/questions/254457/â¦
â dhag
May 3 at 16:53
I want to limit the amount of food I eat, but I donâÂÂt want to monitor my food intake.â What?â If you donâÂÂt want to âÂÂuseâ¯timeâÂÂ,â what is your question?
â Scott
May 3 at 22:20
Here is a similar question: unix.stackexchange.com/questions/254457/â¦
â dhag
May 3 at 16:53
Here is a similar question: unix.stackexchange.com/questions/254457/â¦
â dhag
May 3 at 16:53
I want to limit the amount of food I eat, but I donâÂÂt want to monitor my food intake.â What?â If you donâÂÂt want to âÂÂuseâ¯timeâÂÂ,â what is your question?
â Scott
May 3 at 22:20
I want to limit the amount of food I eat, but I donâÂÂt want to monitor my food intake.â What?â If you donâÂÂt want to âÂÂuseâ¯timeâÂÂ,â what is your question?
â Scott
May 3 at 22:20
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
/path/to/job.py &
pid=$!
sleep 30
if kill -0 $pid; then kill -TERM $pid; fi
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
/path/to/job.py &
pid=$!
sleep 30
if kill -0 $pid; then kill -TERM $pid; fi
add a comment |Â
up vote
0
down vote
accepted
/path/to/job.py &
pid=$!
sleep 30
if kill -0 $pid; then kill -TERM $pid; fi
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
/path/to/job.py &
pid=$!
sleep 30
if kill -0 $pid; then kill -TERM $pid; fi
/path/to/job.py &
pid=$!
sleep 30
if kill -0 $pid; then kill -TERM $pid; fi
answered May 3 at 16:58
DopeGhoti
40k54779
40k54779
add a comment |Â
add a comment |Â
Here is a similar question: unix.stackexchange.com/questions/254457/â¦
â dhag
May 3 at 16:53
I want to limit the amount of food I eat, but I donâÂÂt want to monitor my food intake.â What?â If you donâÂÂt want to âÂÂuseâ¯timeâÂÂ,â what is your question?
â Scott
May 3 at 22:20