test sh run in background

This commit is contained in:
JamesonHuang 2015-07-02 22:53:31 +08:00
parent 6f2559d341
commit a35331f35d
4 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#!/bin/bash
function fileNum(){
while true
do
echo "sleep background"
sleep 5
done
}
fileNum &
while true
do
echo "sleep foreground"
sleep 1
done

View File

@ -0,0 +1,3 @@
#!/bin/bash
sh -c "exec ./test.sh"
echo abc

14
1_3.test_code/sh_test/random.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
random_num=$(date +%s%N)
echo $random_num
#指定范围随机数
rand(){
min=$1
max=$(($2-$min+1))
num=$(date +%s%N)
echo $(($num%$max+$min))
}
random_num2=$(rand 1 3)
sleep ${random_num2}
echo $random_num2

3
1_3.test_code/sh_test/test.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
ps
echo "hello world"