date.sh
for((;;))
do
date
done
test.sh
case $1 in
"start"){
echo "==== 1. 启动 date.sh ===="
nohup sh date.sh > test.log 2>&1 &
tail -f test.log
};;
"stop"){
echo "==== 2. 停止 date.sh ===="
ps -ef|grep -v "grep"|grep "date.sh"|awk '{print $2}'|xargs kill -9
};;
"status"){
echo "==== 3. 查看 date.sh 进程状态 ===="
ps -ef|grep -v "grep"|grep "date.sh"
};;
esac
脚本使用
启动
sh test.sh start
停止
sh test.sh stop
查看状态
sh test.sh status