4

macOS使用终端关闭/打开(重新启动)APP应用程序

 3 years ago
source link: https://www.itpwd.com/418.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
macOS使用终端关闭/打开(重新启动)APP应用程序_Mac笔记_IT密码

虽然是很简单的步骤,也为了记录一下,注意大小写

这里使用TeamViewer举例,os是用户名,TeamViewer是应用程序的名字,获取程序的进程ID(PID)

ps -axu os | grep TeamViewer

输出可见TeamViewer进程的PID为6969,使用命令杀死此程序对应的PID

kill -9 6969

如果不知道程序名字,查看程序名字

ls /Applications/

带abc.doc参数打开Word程序可打开abc.doc文件,如果不需要打开文件请忽略

open -a "Microsoft Word.app" abc.doc

ps命令解析:

-a   列出所有用户(包括第三方)的进程信息,但不包括无控制终端的进程

-u   列出属于某用户的进程,这里是 os

-x   包括无控制终端的进程

最后通过管道利用 grep 筛选我们需要的进程信息。

kill命令解析:

kill 将指定的信息送至程序,默认信号 SIGTERM (15),可将指定程序终止

-9 向进程发送 SIGKILL (9) 信号,强制终止进程;本信号不能被阻塞、处理和忽略。

open命令解析:

详情参考open --help


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK