如何自定义后端运行作业完成消息?

如何自定义后端运行作业完成消息?

情况是这样的,我正在 bash shell (Ubuntu) 中运行一个命令(我自己的执行人员),说这样的话:

[newbie@office currentCaseAFolder]$ FEMSolver &

因此该FEMSolver作业现在正在后端运行,假设它需要大约五到十分钟。但我有多个案例。所以

[newbie@office currentCaseAFolder]$ cd ../currentCaseBFolder
[newbie@office currentCaseBFolder]$ FEMSolver &
[newbie@office currentCaseBFolder]$ cd ../currentCaseCFolder
[newbie@office currentCaseCFolder]$ FEMSolver &
[newbie@office currentCaseCFolder]$ cd ../currentCaseDFolder
[newbie@office currentCaseDFolder]$ FEMSolver &
[newbie@office currentCaseDFolder]$ cd ../../postprocessingFolder

喝完咖啡后,我回来,按回车键,一些模拟已经完成。所以它会告诉我

[2]  + Done           FEMSolver &
[4]  + Done           FEMSolver &
[newbie@office postprocessingFolder]$ 

但这并没有给我明确的信息,该作业是从哪个文件夹发送的!我希望它可以在某个地方并以某种方式进行定制以达到这种效果:

[2]  + Done           FEMSolver &  (from folder currentCaseBFolder)
[2]  + Done           FEMSolver &  (from folder currentCaseDFolder)
[newbie@office postprocessingFolder]$

有任何想法吗?

答案1

您可以将cd和包装FEMSolver到后台子 shell 中,如下所示:

(cd currentCaseAFolder; FEMSolver) &

当它们完成运行时,您将收到类似以下内容的消息。

[2]+  Done                    ( cd currentCaseBFolder; FEMSolver)
[4]+  Done                    ( cd currentCaseDFolder; FEMSolver)

相关内容