2021-01-21 linux shell脚本实现间隔一定时间执行一次任务

shell脚本实现间隔一定时间执行一次任务

1.编写shell脚本

while [ true ]; do
sleep 20
bash test.sh  >> /tmp/date.txt
done

2.后台运行

nohup bash test.sh 2>&1 > /dev/null &

3.确认每秒执行

tail -f /tmp/date.txt

4. 停止脚本运行进程

ps -ef | grep test.sh |kill -9

猜你喜欢

转载自blog.csdn.net/qingfengxd1/article/details/112966607