shell脚本实现每秒执行一次任务

1.编写shell脚本

vi /tmp/ceshi.sh
!/bin/sh
while [ true ]; do
/bin/sleep 1
/bin/date >>/tmp/date.txt
done

2.后台运行

nohup /tmp/ceshi.sh 2>&1 > /dev/null &

3.确认每秒执行

tail -f /tmp/date.txt

4. 停止脚本运行进程

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

猜你喜欢

转载自blog.csdn.net/yinhuaiya/article/details/80336886