Call a function using nohup

前端 未结 6 1714
滥情空心
滥情空心 2020-12-10 10:59

I am trying to call a function using nohup like this:

function1(){
    while true 
    do
        echo \"function1\"
        sleep 1
    done
}
         


        
6条回答
  •  失恋的感觉
    2020-12-10 11:57

    Instead of using nohup, which is tailored for files, you can implement the same result like this:

    (trap '' HUP INT
     while true
     do
       echo "function1"
       sleep 1
     done
    ) &1 1>nohup.out &
    

    As I tend to launch these processes from a parent script and the parent script may do other work if the parent process is interrupted I want the child process to ignore the INT signal and keep on running.

提交回复
热议问题