1. 程式人生 > >shell指令碼實現每秒執行一次任務

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