mirror of
https://github.com/JamesonHuang/OpenWrt_Luci_Lua.git
synced 2024-11-23 13:50:11 +00:00
test sh run in background
This commit is contained in:
parent
6f2559d341
commit
a35331f35d
15
1_3.test_code/sh_test/background_exec.sh
Executable file
15
1_3.test_code/sh_test/background_exec.sh
Executable 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
|
||||
|
3
1_3.test_code/sh_test/fork_shell.sh
Executable file
3
1_3.test_code/sh_test/fork_shell.sh
Executable 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
14
1_3.test_code/sh_test/random.sh
Executable 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
3
1_3.test_code/sh_test/test.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
ps
|
||||
echo "hello world"
|
Loading…
Reference in New Issue
Block a user