使用nohup调用一个函数 [英] Call a function using nohup
本文介绍了使用nohup调用一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用 nohup
来调用函数,如下所示:
function1(){
while true
do
echofunction1
sleep 1
done
}
nohup功能1&
#......其他一些代码
但可能是函数isn' nohup
,我得到这个错误:
nohup:failed运行命令`function1':没有这样的文件或字典
我不想创建新的sh文件为我的功能。如何解决这个问题?
解决方案
另一个解决方案:
<$ p $ function background {
echo TEST
}
export -f background
nohup bash -c background&
I am trying to call a function using nohup
like this:
function1(){
while true
do
echo "function1"
sleep 1
done
}
nohup function1 &
# ...... some other code
but may be the function isn't seen by nohup
and I get this error:
nohup: failed to run command `function1' : No such file or dictionary
I don't want to create new sh file for my function. How can I fix this?
解决方案
Another solution:
function background {
echo TEST
}
export -f background
nohup bash -c background &
这篇关于使用nohup调用一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文