问题描述
在 BAT 文件中,我启动了 2 个单独的进程,如下所示:如您所见,唯一的区别是 CPU 亲和性.
In a BAT file I start 2 separate processes like so:As you can see the only difference is the CPU affinity.
start /realtime /affinity FFFF C:\Users\telis\Documents\CHIA\madmax\plotter\chia_plot.exe
start /realtime /affinity FFFF0000 C:\Users\telis\Documents\CHIA\madmax\plotter\chia_plot.exe
有时,两个进程之一会随机失败,并显示:问题事件名称:BEX64
Sometimes, randomly, one of the 2 processes fails with:Problem Event Name: BEX64
当发生此类故障时,必须立即重新启动进程.所以我面临这个问题.
It is essential that the process is restarted immediately when a failure like this happens. So I am faced with this problem.
我可以在 BAT 文件中监控 2 个进程,如果一个进程失败重启吗?监控过程必须能够区分哪些2 个进程中的一个失败,因此使用正确的亲缘关系重新启动它.
如果您有涉及 powershell 的解决方案,请访问 如果在 Windows Powershell 中失败,如何重新启动特定命令?
If you have a solution involving powershell please visit How to RESTART a specific command if it fails in Windows Powershell?
谢谢
推荐答案
您是否有 32 个处理器可以使用?通过使用-PassThru
,可以使用进程对象来监控进程是否还活着.
Do you have 32 processors with which to work? By using -PassThru
, the process object can be used to monitor if the process is still alive.
$Process1 = Start-Process -FilePath 'C:\Users\telis\Documents\CHIA\madmax\plotter\chia_plot.exe' -PassThru
$Process1.ProcessorAffinity = 0xF
$Process1.PriorityClass = 'RealTime'
$Process2 = Start-Process -FilePath 'C:\Users\telis\Documents\CHIA\madmax\plotter\chia_plot.exe' -PassThru
$Process2.ProcessorAffinity = 0xF0
$Process2.PriorityClass = 'RealTime'
这篇关于如果在 Windows 批处理文件中失败,如何重新启动特定命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!