I am trying to call a function using nohup like this:
function1(){
while true
do
echo \"function1\"
sleep 1
done
}
nohup applies to commands and not to script functions.
For example, the script (say func.sh) that contains function1() should call the function-:
function1(){
while true
do
echo "function1"
sleep 1
done
}
function1
Now call the script func.sh with nohup in the background-:
nohup ./func.sh &
If you need to disable the hangup signal from within the script use the shell built-in trap. The example ignores SIGHUP but can be used to ignore others (e.g. SIGINT).
trap "" HUP # script will ignore HANGUP signal