Stop an application through terminal [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
开发者_如何学编程 Improve this questionI am using Ubuntu and i would like to stop a running application from terminal, more precisely through a script. One way is to get the pid of the process and issue a kill command with the pid of the process. But how do i get the pid of running applications? Or is there any better way to do this?
you can use
ps -ax | grep application name if your searching for firefox type below command
ps -ax | grep firefox
it shows the processing id of corresponding applications you can stop that application by kill command if process id=1317,
kill -9 1317
How to stop an application from opening at start?
You will have to type ps -A
and Enter.
After that you will get a list of every app that that is starting by itself.
kill -9 (the number of the app)
Send me a message it that does not help you.
If you know the name of the application:
$ pidof "name of application" (This will return the pid of that application)
$ kill -9 "pid"
Here is a basic bash script I wrote:
#!/bin/bash
PID=`pidof start_program`
kill $PID
"start_program" is the name of the application running.
ps -ef | grep application name
pkill will probably cover your use case.
Or is there any better way to do this?
Depends on the application. Some applications write their PID to a file.
精彩评论