监听ctrl+c和15信号

function quit() {
    time=$(date "+%Y-%m-%d %H:%M:%S")
    echo "$time quit"
    exit 0
}

# 捕捉ctrl+c
trap quit SIGINT
# 捕捉15
trap quit SIGTERM

while true
do
    sleep 1
done

posted on 2024-06-29 17:44  王景迁  阅读(12)  评论(0编辑  收藏  举报

导航