27 hours ago
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?
1 hours ago
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.
31 hours ago
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.
13 hours ago
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.
$ sleep 100 &
$ sleep 101 &
$ sleep 102 &
$ sleep 103 &
$ sleep 104 &
$ sleep 105 &
$ sleep 106 &
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
$ fg 7
4 hours ago
Launch a new tab of terminal, run:
$ pgrep ping
Then kill the pid using kill command:
$ kill 2564
17 hours ago
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 &
ping -c 100 192.168.1.1 &
28 hours ago
When you are root, it's simply killall ping.
12 hours ago
kill -9 %%
and it will kill the current background process you're running.
11 hours ago
You can see all the process that you put in background (for current session ) with jobs command
After you run this command you will see all the process which are running on the current bash and on the left side of each process you can see some numbers :
- Running sleep 200000 &
+ Running sleep 300000 &
You can simply terminate jobs (processes) by using kill -15 n% (n is a number that is in [ sign )
kill -15 n%
-15 is for terminating process nicely , if you want to force close the process, just use -9 instead of -15
PS : It is obvious if you run a command with root privilege , you have to run kill -15 n% with sudo
2) You can see all of the process that are running on the system with ps -aux and for seeing ping :
ps -aux | grep ping
The output is like :
root 2615 0.0 0.0 25828 1052 pts/0 S 02:12 0:00 ping 126.96.36.199
The second number (2615) is PID or process ID and you can terminate the process with
sudo kill -15 2615