在下面的脚本中,ivfstudio 命令打开一个 GUI。即使作为后台进程启动,我也需要先关闭它,以便执行下一个命令。如何让它成为“真正的背景”?
#!/bin/sh
cmd=`ivfstudio ilv/my_app.iva -execute GenerateAll `;
(
$cmd & ;
echo "toto" ;
`sleep 30` ;
PID = `ps aux | grep -i ivfs | grep my_user| grep -i generateall | awk -F " " '{print $2}' \`; ) ) ` ;
echo $(PID) ;
`kill $(PID)` ;
)
exit
编辑解决方案:
#!/bin/sh
cmd="ivfstudio my_project.iva -execute GenerateAll > /dev/null 2> /dev/null"
nohup $cmd &
echo "toto"
`sleep 30`
PID=`ps aux | grep -i ivfs | grep my_user| grep -i generateall | awk -F " " '{print $2}' `
echo $PID
`kill $PID`
exit