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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章