gpt4 book ai didi

linux - 使用 nohup 调用函数

转载 作者:IT王子 更新时间:2023-10-29 00:22:32 24 4
gpt4 key购买 nike

我正在尝试使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com