Answer the question
In order to leave comments, you need to log in
How to “throw away” part of the script or wrap it in a screen?
Good day. I have a question like this. I'm still a beginner "clerk" =) So there are some developments in the bash. So, is it possible in some way, for example, to wrap part of the script (its execution) into a screen?! Well, so that he would not "create a queue" so to speak ?!
PS Thanks in advance!
Answer the question
In order to leave comments, you need to log in
All methods are different
#!/bin/bash
# отправить в бекграунд
source /path/to/sub_script.sh &
# отправить в бекграунд и отвязаться от текущей консоли
source /path/to/sub_script.sh &!
# man exec
exec /path/to/sub_script.sh
# man nohup
nohup /path/to/sub_script.sh
# cat << EOF | nohup sh
# cat << EOF | exec sh
# cat << EOF | sh &!
cat << EOF | sh &
# content of my sub_script.sh
echo `date` > /tmp/123
EOF
# замечание
# sh != bash
# если у тебя скрипт оттестирован на баше, то делай cat << EOF | nohup bash
Part of the script is unlikely, but this can be done with a separate command, or save part of the script in another script and call it in the background with
nohup
So is it possible in some way, for example, to wrap part of the script (its execution) into a screen?
#!/bin/bash
func1()
{
for i in {1..5}; do
echo 1
sleep 2
done
}
func2()
{
for i in {1..5}; do
echo 2
sleep 4
done
}
func3()
{
echo 3
func1 &
sleep 1
echo 4
func2 &
sleep 1
echo 5
wait
}
func3
exit 0
[[email protected] sh]$ ./t.sh
3
1
4
2
1
5
1
2
1
1
2
2
2
[[email protected] sh]$
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question