shell/控制脚本/捕捉信号.sh

17 lines
220 B
Bash
Raw Normal View History

2016-05-15 09:51:46 +08:00
#!/bin/bash
# testing signal trapping
trap "echo 'Sorry! I have trapped Ctrl-C'" SIGINT SIGTERM
echo this is a test program
count=1
while [ $count -le 10 ]
do
echo "Loop #$count"
sleep 5
count=$[ $count+1 ]
done