只需打开任务管理器,就可以看到Windows操作系统中有进程列表。现在我的问题是,是否可以从Mathematica前端关闭一个这样的过程。
我的意思是我们需要编写一个脚本来杀死" Process Tree"如果进程占用系统RAM的95%以上,或者需要超过X分钟或几秒钟才能完成。我不知道是否可以通过MMA完成,但如果可能,它将在我的项目中变得非常方便。
BR
答案 0 :(得分:2)
您可能希望使用Run
函数和TSKILL
shell命令。
TSKILL processid | processname [/SERVER:servername] [/ID:sessionid | /A] [/V]
processid Process ID for the process to be terminated.
processname Process name to be terminated.
/SERVER:servername Server containing processID (default is current).
/ID or /A must be specified when using processname
and /SERVER
/ID:sessionid End process running under the specified session.
/A End process running under ALL sessions.
/V Display information about actions being performed.
答案 1 :(得分:2)
我使用了一种方法在我的回复中关闭了一个进程:
How can I make Mathematica kernel pause for an external file creation
taskkill /f /fi "imagename eq apame_win64.exe"
E.g。关闭记事本:
ReadList["!taskkill /F /FI \"IMAGENAME eq notepad.exe\"", String]
这可以与任务列表结合使用来识别内存使用:
ReadList["!tasklist", String]