I have this timeout code block:
#!/bin/bash
WB=$1
sleep 2h;
commands...
kill $WB
To run the script with nohup
and in the background, I can paste it in a file, and execute:
nohup /opt/myscript.sh $$ &
What I aim to achieve:
Instead of pasting it in a file and execute, I would like to execute it directly from an heredoc:
/dev/fd/10 10<< 'EOF0'
#!/bin/bash
WB=$1
sleep 2h;
commands...
kill $WB
EOF0
I use an heredoc because heredocs are the only way to paste whole code-blocks directly into Bash, and then execute - Very efficient in my case.
My question:
How could I correctly use nohup
and &
with the above hereodc?
Note that the above heredoc is a special one, it's an external heredoc (EOF0), allowing 1 or more heredocs inside it (EOF1, EOF2...).