I am trying to call a function using nohup
like this:
function1(){
while true
do
echo \"function1\"
sleep 1
done
}
Yes ! It is possible however tricky, and strictly bash > v2 compatible :
function1(){ local msg=${*:-function1}; echo msg=$msg; }
nohup -- sh -c "$(typeset -f function1); function1 MESSAGE" >nohup.log 2>&1 0
And don't forget "typeset" is bash deprecated in favor of "declare" (though I don't entirely agree with this).