KShell后台任务未显示在作业中

时间:2009-10-30 14:06:06

标签: shell ksh background-process

我编写了一个简单的KShell脚本来启动后台任务

#/bin/ksh 
#startMonitoring

./detectFile /usr/local/data/testFile > fileHistory &

我使用以下命令运行它

startMonitoring

当我运行作业时,我没有得到任何结果,但命令正在运行并显示在ps中:

  

512232 pts / 0 0:34 / bin / ksh ./detectFile / usr / local / data / testFile

为什么我不能在作业中看到该项目,如何更改我的脚本以便它显示在作业中?

1 个答案:

答案 0 :(得分:1)

jobs命令仅查找当前shell。脚本在自己的shell中运行。如果您改为使用脚本,那么jobs会显示它:

$ . startMonitoring
$ jobs
[1] +  Running                 . startMonitoring