10 Oct 2019
# $? 上个命令的执行结果 # 执行成功返回0值 rm -rf test.sh echo $? 0 # 执行失败返回非0值 ls test.sh ls: test.sh: No such file or directory echo $? 1 ll -bash: ll: command not found echo $? 127
cat << EOF > /tmp/test.sh #!/bin/bash echo $$ while :; do echo test sleep 60 done EOF sh test.sh 13920 test ^Z [1]+ Stopped sh test.sh ps aux |grep test.sh|grep -v grep user 13920 0.0 0.0 4268636 1156 s000 T 1:52PM 0:00.00 sh test.sh