How to terminate ping &
The command
ping <dest> &
causes ping to go to the background. It still prints output to the terminal, however. Ctrl-C does not stop it, only introduces a new prompt. How to stop it from the terminal?
command-line
|
show 1 more comment
The command
ping <dest> &
causes ping to go to the background. It still prints output to the terminal, however. Ctrl-C does not stop it, only introduces a new prompt. How to stop it from the terminal?
command-line
In addition to the answers, there is a way to naturally limitping
's iterations with a count —-c N
— where N is a positive number.
– l0b0
Mar 15 at 18:07
1
@l0b0 Yes true, but I faced this particular problem, and it's actually related to any program where we might not know the execution time, or where it might not even be defined. So I mean to ask how to stop the process.
– Vineet
Mar 15 at 18:20
Nitpick: It's not a URL.
– Roger Lipscombe
Mar 15 at 18:43
@RogerLipscombe What do you call it, other than destination? Host is a little unsure, considering that a single computer may host many domains
– Vineet
Mar 15 at 18:48
It's a hostname (or an IP address). "a single computer may host many domains" -- not relevant to ping.
– Roger Lipscombe
Mar 15 at 19:14
|
show 1 more comment
The command
ping <dest> &
causes ping to go to the background. It still prints output to the terminal, however. Ctrl-C does not stop it, only introduces a new prompt. How to stop it from the terminal?
command-line
The command
ping <dest> &
causes ping to go to the background. It still prints output to the terminal, however. Ctrl-C does not stop it, only introduces a new prompt. How to stop it from the terminal?
command-line
command-line
edited Mar 15 at 18:45
Vineet
asked Mar 15 at 14:13
VineetVineet
467
467
In addition to the answers, there is a way to naturally limitping
's iterations with a count —-c N
— where N is a positive number.
– l0b0
Mar 15 at 18:07
1
@l0b0 Yes true, but I faced this particular problem, and it's actually related to any program where we might not know the execution time, or where it might not even be defined. So I mean to ask how to stop the process.
– Vineet
Mar 15 at 18:20
Nitpick: It's not a URL.
– Roger Lipscombe
Mar 15 at 18:43
@RogerLipscombe What do you call it, other than destination? Host is a little unsure, considering that a single computer may host many domains
– Vineet
Mar 15 at 18:48
It's a hostname (or an IP address). "a single computer may host many domains" -- not relevant to ping.
– Roger Lipscombe
Mar 15 at 19:14
|
show 1 more comment
In addition to the answers, there is a way to naturally limitping
's iterations with a count —-c N
— where N is a positive number.
– l0b0
Mar 15 at 18:07
1
@l0b0 Yes true, but I faced this particular problem, and it's actually related to any program where we might not know the execution time, or where it might not even be defined. So I mean to ask how to stop the process.
– Vineet
Mar 15 at 18:20
Nitpick: It's not a URL.
– Roger Lipscombe
Mar 15 at 18:43
@RogerLipscombe What do you call it, other than destination? Host is a little unsure, considering that a single computer may host many domains
– Vineet
Mar 15 at 18:48
It's a hostname (or an IP address). "a single computer may host many domains" -- not relevant to ping.
– Roger Lipscombe
Mar 15 at 19:14
In addition to the answers, there is a way to naturally limit
ping
's iterations with a count — -c N
— where N is a positive number.– l0b0
Mar 15 at 18:07
In addition to the answers, there is a way to naturally limit
ping
's iterations with a count — -c N
— where N is a positive number.– l0b0
Mar 15 at 18:07
1
1
@l0b0 Yes true, but I faced this particular problem, and it's actually related to any program where we might not know the execution time, or where it might not even be defined. So I mean to ask how to stop the process.
– Vineet
Mar 15 at 18:20
@l0b0 Yes true, but I faced this particular problem, and it's actually related to any program where we might not know the execution time, or where it might not even be defined. So I mean to ask how to stop the process.
– Vineet
Mar 15 at 18:20
Nitpick: It's not a URL.
– Roger Lipscombe
Mar 15 at 18:43
Nitpick: It's not a URL.
– Roger Lipscombe
Mar 15 at 18:43
@RogerLipscombe What do you call it, other than destination? Host is a little unsure, considering that a single computer may host many domains
– Vineet
Mar 15 at 18:48
@RogerLipscombe What do you call it, other than destination? Host is a little unsure, considering that a single computer may host many domains
– Vineet
Mar 15 at 18:48
It's a hostname (or an IP address). "a single computer may host many domains" -- not relevant to ping.
– Roger Lipscombe
Mar 15 at 19:14
It's a hostname (or an IP address). "a single computer may host many domains" -- not relevant to ping.
– Roger Lipscombe
Mar 15 at 19:14
|
show 1 more comment
6 Answers
6
active
oldest
votes
First enter fg
into same terminal that your ping
command is running (it brings the process into the foreground), then press Ctrl+c to stop the process.
This works. I also realized that fg works if we have multiple background processes, by calling them to the foreground one by one.
– Vineet
Mar 15 at 14:22
Yep, that's how it works, you can usejobs
to get a list of process that are running in background.
– Ravexina
Mar 15 at 14:23
How did you make that image loop?
– phillipsk
Mar 16 at 18:25
3
@phillipsk It's GIF, that's how GIF works ...
– Ravexina
Mar 16 at 18:31
add a comment |
If it is your one and only background job you can kill it with kill %1
. If not sure you can list all your background jobs with jobs
and use kill %<n>
where you replace n by the number of your ping job.
4
Also, I found out that n matches the number that is print out in square brackets when running the command.
– Vineet
Mar 15 at 14:31
add a comment |
When you send a process to the background, whether by using ctrl-z or by &
at the end of the command, you get an output in the following format: [index] process-id
. If you send multiple processes to the background, the index will keep incrementing every time.
For example:
$ sleep 100 &
[1] 41608
$ sleep 101 &
[2] 41609
$ sleep 102 &
[3] 41610
$ sleep 103 &
[4] 41611
$ sleep 104 &
[5] 41612
$ sleep 105 &
[6] 41613
$ sleep 106 &
[7] 41614
In order to stop a specific one, you can either use kill <process-id>
or use fg <index>
followed by ctrl-c
Example using the previous output:
$ kill 41614
or
$ fg 7
sleep 106
^C
add a comment |
Launch a new tab of terminal, run:
$ pgrep ping
2564
Then kill the pid using kill
command:
$ kill 2564
I used kill in the same terminal too (though the output made it difficult to use). However, I was wondering what to do if I couldn't go far back up in the terminal to see the process id printed, so pgrep has helped, additionally.
– Vineet
Mar 15 at 14:24
2
When you usepgrep
to search processes by name, you can also usepkill
to kill them by name. No need to type/copy the process id and usekill
.
– Byte Commander
Mar 15 at 14:29
This is useful to know, but for this question it's a bit of overkill. :-p
– tudor
Mar 18 at 1:45
add a comment |
When you are root, it's simply killall ping
.
add a comment |
Slightly different approach towards a continuous ping is to use -c option and enter the number of time you want it to run, that way it will stop itself after the desired count i.e. below ping will stop after 100 pings
ping -c 100 192.168.1.1 &
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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%2faskubuntu.com%2fquestions%2f1125926%2fhow-to-terminate-ping-dest%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
First enter fg
into same terminal that your ping
command is running (it brings the process into the foreground), then press Ctrl+c to stop the process.
This works. I also realized that fg works if we have multiple background processes, by calling them to the foreground one by one.
– Vineet
Mar 15 at 14:22
Yep, that's how it works, you can usejobs
to get a list of process that are running in background.
– Ravexina
Mar 15 at 14:23
How did you make that image loop?
– phillipsk
Mar 16 at 18:25
3
@phillipsk It's GIF, that's how GIF works ...
– Ravexina
Mar 16 at 18:31
add a comment |
First enter fg
into same terminal that your ping
command is running (it brings the process into the foreground), then press Ctrl+c to stop the process.
This works. I also realized that fg works if we have multiple background processes, by calling them to the foreground one by one.
– Vineet
Mar 15 at 14:22
Yep, that's how it works, you can usejobs
to get a list of process that are running in background.
– Ravexina
Mar 15 at 14:23
How did you make that image loop?
– phillipsk
Mar 16 at 18:25
3
@phillipsk It's GIF, that's how GIF works ...
– Ravexina
Mar 16 at 18:31
add a comment |
First enter fg
into same terminal that your ping
command is running (it brings the process into the foreground), then press Ctrl+c to stop the process.
First enter fg
into same terminal that your ping
command is running (it brings the process into the foreground), then press Ctrl+c to stop the process.
edited Mar 15 at 23:02
answered Mar 15 at 14:17
RavexinaRavexina
33.3k1488115
33.3k1488115
This works. I also realized that fg works if we have multiple background processes, by calling them to the foreground one by one.
– Vineet
Mar 15 at 14:22
Yep, that's how it works, you can usejobs
to get a list of process that are running in background.
– Ravexina
Mar 15 at 14:23
How did you make that image loop?
– phillipsk
Mar 16 at 18:25
3
@phillipsk It's GIF, that's how GIF works ...
– Ravexina
Mar 16 at 18:31
add a comment |
This works. I also realized that fg works if we have multiple background processes, by calling them to the foreground one by one.
– Vineet
Mar 15 at 14:22
Yep, that's how it works, you can usejobs
to get a list of process that are running in background.
– Ravexina
Mar 15 at 14:23
How did you make that image loop?
– phillipsk
Mar 16 at 18:25
3
@phillipsk It's GIF, that's how GIF works ...
– Ravexina
Mar 16 at 18:31
This works. I also realized that fg works if we have multiple background processes, by calling them to the foreground one by one.
– Vineet
Mar 15 at 14:22
This works. I also realized that fg works if we have multiple background processes, by calling them to the foreground one by one.
– Vineet
Mar 15 at 14:22
Yep, that's how it works, you can use
jobs
to get a list of process that are running in background.– Ravexina
Mar 15 at 14:23
Yep, that's how it works, you can use
jobs
to get a list of process that are running in background.– Ravexina
Mar 15 at 14:23
How did you make that image loop?
– phillipsk
Mar 16 at 18:25
How did you make that image loop?
– phillipsk
Mar 16 at 18:25
3
3
@phillipsk It's GIF, that's how GIF works ...
– Ravexina
Mar 16 at 18:31
@phillipsk It's GIF, that's how GIF works ...
– Ravexina
Mar 16 at 18:31
add a comment |
If it is your one and only background job you can kill it with kill %1
. If not sure you can list all your background jobs with jobs
and use kill %<n>
where you replace n by the number of your ping job.
4
Also, I found out that n matches the number that is print out in square brackets when running the command.
– Vineet
Mar 15 at 14:31
add a comment |
If it is your one and only background job you can kill it with kill %1
. If not sure you can list all your background jobs with jobs
and use kill %<n>
where you replace n by the number of your ping job.
4
Also, I found out that n matches the number that is print out in square brackets when running the command.
– Vineet
Mar 15 at 14:31
add a comment |
If it is your one and only background job you can kill it with kill %1
. If not sure you can list all your background jobs with jobs
and use kill %<n>
where you replace n by the number of your ping job.
If it is your one and only background job you can kill it with kill %1
. If not sure you can list all your background jobs with jobs
and use kill %<n>
where you replace n by the number of your ping job.
answered Mar 15 at 14:25
mucluxmuclux
3,26111130
3,26111130
4
Also, I found out that n matches the number that is print out in square brackets when running the command.
– Vineet
Mar 15 at 14:31
add a comment |
4
Also, I found out that n matches the number that is print out in square brackets when running the command.
– Vineet
Mar 15 at 14:31
4
4
Also, I found out that n matches the number that is print out in square brackets when running the command.
– Vineet
Mar 15 at 14:31
Also, I found out that n matches the number that is print out in square brackets when running the command.
– Vineet
Mar 15 at 14:31
add a comment |
When you send a process to the background, whether by using ctrl-z or by &
at the end of the command, you get an output in the following format: [index] process-id
. If you send multiple processes to the background, the index will keep incrementing every time.
For example:
$ sleep 100 &
[1] 41608
$ sleep 101 &
[2] 41609
$ sleep 102 &
[3] 41610
$ sleep 103 &
[4] 41611
$ sleep 104 &
[5] 41612
$ sleep 105 &
[6] 41613
$ sleep 106 &
[7] 41614
In order to stop a specific one, you can either use kill <process-id>
or use fg <index>
followed by ctrl-c
Example using the previous output:
$ kill 41614
or
$ fg 7
sleep 106
^C
add a comment |
When you send a process to the background, whether by using ctrl-z or by &
at the end of the command, you get an output in the following format: [index] process-id
. If you send multiple processes to the background, the index will keep incrementing every time.
For example:
$ sleep 100 &
[1] 41608
$ sleep 101 &
[2] 41609
$ sleep 102 &
[3] 41610
$ sleep 103 &
[4] 41611
$ sleep 104 &
[5] 41612
$ sleep 105 &
[6] 41613
$ sleep 106 &
[7] 41614
In order to stop a specific one, you can either use kill <process-id>
or use fg <index>
followed by ctrl-c
Example using the previous output:
$ kill 41614
or
$ fg 7
sleep 106
^C
add a comment |
When you send a process to the background, whether by using ctrl-z or by &
at the end of the command, you get an output in the following format: [index] process-id
. If you send multiple processes to the background, the index will keep incrementing every time.
For example:
$ sleep 100 &
[1] 41608
$ sleep 101 &
[2] 41609
$ sleep 102 &
[3] 41610
$ sleep 103 &
[4] 41611
$ sleep 104 &
[5] 41612
$ sleep 105 &
[6] 41613
$ sleep 106 &
[7] 41614
In order to stop a specific one, you can either use kill <process-id>
or use fg <index>
followed by ctrl-c
Example using the previous output:
$ kill 41614
or
$ fg 7
sleep 106
^C
When you send a process to the background, whether by using ctrl-z or by &
at the end of the command, you get an output in the following format: [index] process-id
. If you send multiple processes to the background, the index will keep incrementing every time.
For example:
$ sleep 100 &
[1] 41608
$ sleep 101 &
[2] 41609
$ sleep 102 &
[3] 41610
$ sleep 103 &
[4] 41611
$ sleep 104 &
[5] 41612
$ sleep 105 &
[6] 41613
$ sleep 106 &
[7] 41614
In order to stop a specific one, you can either use kill <process-id>
or use fg <index>
followed by ctrl-c
Example using the previous output:
$ kill 41614
or
$ fg 7
sleep 106
^C
answered Mar 15 at 14:43
DanDan
7,19034573
7,19034573
add a comment |
add a comment |
Launch a new tab of terminal, run:
$ pgrep ping
2564
Then kill the pid using kill
command:
$ kill 2564
I used kill in the same terminal too (though the output made it difficult to use). However, I was wondering what to do if I couldn't go far back up in the terminal to see the process id printed, so pgrep has helped, additionally.
– Vineet
Mar 15 at 14:24
2
When you usepgrep
to search processes by name, you can also usepkill
to kill them by name. No need to type/copy the process id and usekill
.
– Byte Commander
Mar 15 at 14:29
This is useful to know, but for this question it's a bit of overkill. :-p
– tudor
Mar 18 at 1:45
add a comment |
Launch a new tab of terminal, run:
$ pgrep ping
2564
Then kill the pid using kill
command:
$ kill 2564
I used kill in the same terminal too (though the output made it difficult to use). However, I was wondering what to do if I couldn't go far back up in the terminal to see the process id printed, so pgrep has helped, additionally.
– Vineet
Mar 15 at 14:24
2
When you usepgrep
to search processes by name, you can also usepkill
to kill them by name. No need to type/copy the process id and usekill
.
– Byte Commander
Mar 15 at 14:29
This is useful to know, but for this question it's a bit of overkill. :-p
– tudor
Mar 18 at 1:45
add a comment |
Launch a new tab of terminal, run:
$ pgrep ping
2564
Then kill the pid using kill
command:
$ kill 2564
Launch a new tab of terminal, run:
$ pgrep ping
2564
Then kill the pid using kill
command:
$ kill 2564
answered Mar 15 at 14:17
EmmetEmmet
7,14822245
7,14822245
I used kill in the same terminal too (though the output made it difficult to use). However, I was wondering what to do if I couldn't go far back up in the terminal to see the process id printed, so pgrep has helped, additionally.
– Vineet
Mar 15 at 14:24
2
When you usepgrep
to search processes by name, you can also usepkill
to kill them by name. No need to type/copy the process id and usekill
.
– Byte Commander
Mar 15 at 14:29
This is useful to know, but for this question it's a bit of overkill. :-p
– tudor
Mar 18 at 1:45
add a comment |
I used kill in the same terminal too (though the output made it difficult to use). However, I was wondering what to do if I couldn't go far back up in the terminal to see the process id printed, so pgrep has helped, additionally.
– Vineet
Mar 15 at 14:24
2
When you usepgrep
to search processes by name, you can also usepkill
to kill them by name. No need to type/copy the process id and usekill
.
– Byte Commander
Mar 15 at 14:29
This is useful to know, but for this question it's a bit of overkill. :-p
– tudor
Mar 18 at 1:45
I used kill in the same terminal too (though the output made it difficult to use). However, I was wondering what to do if I couldn't go far back up in the terminal to see the process id printed, so pgrep has helped, additionally.
– Vineet
Mar 15 at 14:24
I used kill in the same terminal too (though the output made it difficult to use). However, I was wondering what to do if I couldn't go far back up in the terminal to see the process id printed, so pgrep has helped, additionally.
– Vineet
Mar 15 at 14:24
2
2
When you use
pgrep
to search processes by name, you can also use pkill
to kill them by name. No need to type/copy the process id and use kill
.– Byte Commander
Mar 15 at 14:29
When you use
pgrep
to search processes by name, you can also use pkill
to kill them by name. No need to type/copy the process id and use kill
.– Byte Commander
Mar 15 at 14:29
This is useful to know, but for this question it's a bit of overkill. :-p
– tudor
Mar 18 at 1:45
This is useful to know, but for this question it's a bit of overkill. :-p
– tudor
Mar 18 at 1:45
add a comment |
When you are root, it's simply killall ping
.
add a comment |
When you are root, it's simply killall ping
.
add a comment |
When you are root, it's simply killall ping
.
When you are root, it's simply killall ping
.
answered Mar 16 at 13:33
Sim SonSim Son
365
365
add a comment |
add a comment |
Slightly different approach towards a continuous ping is to use -c option and enter the number of time you want it to run, that way it will stop itself after the desired count i.e. below ping will stop after 100 pings
ping -c 100 192.168.1.1 &
add a comment |
Slightly different approach towards a continuous ping is to use -c option and enter the number of time you want it to run, that way it will stop itself after the desired count i.e. below ping will stop after 100 pings
ping -c 100 192.168.1.1 &
add a comment |
Slightly different approach towards a continuous ping is to use -c option and enter the number of time you want it to run, that way it will stop itself after the desired count i.e. below ping will stop after 100 pings
ping -c 100 192.168.1.1 &
Slightly different approach towards a continuous ping is to use -c option and enter the number of time you want it to run, that way it will stop itself after the desired count i.e. below ping will stop after 100 pings
ping -c 100 192.168.1.1 &
answered Mar 17 at 9:32
IbraheemIbraheem
235
235
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1125926%2fhow-to-terminate-ping-dest%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
In addition to the answers, there is a way to naturally limit
ping
's iterations with a count —-c N
— where N is a positive number.– l0b0
Mar 15 at 18:07
1
@l0b0 Yes true, but I faced this particular problem, and it's actually related to any program where we might not know the execution time, or where it might not even be defined. So I mean to ask how to stop the process.
– Vineet
Mar 15 at 18:20
Nitpick: It's not a URL.
– Roger Lipscombe
Mar 15 at 18:43
@RogerLipscombe What do you call it, other than destination? Host is a little unsure, considering that a single computer may host many domains
– Vineet
Mar 15 at 18:48
It's a hostname (or an IP address). "a single computer may host many domains" -- not relevant to ping.
– Roger Lipscombe
Mar 15 at 19:14