我正在尝试使用 nohup
调用函数,如下所示:
function1(){
while true
do
echo "function1"
sleep 1
done
}
nohup function1 &
# ...... some other code
但可能是 nohup
看不到该函数,我得到了这个错误:
nohup: failed to run command `function1' : No such file or dictionary
我不想为我的函数创建新的 sh 文件。我该如何解决这个问题?
最佳答案
另一种解决方案:
function background {
echo TEST
}
export -f background
nohup bash -c background &
关于linux - 使用 nohup 调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16435629/