sleep指令介紹
SYNOPSISsleep NUMBER[SUFFIX]...
SUFFIX may be ‘s’ for seconds (the default), ‘m’ for minutes, ‘h’ for hours or ‘d’ for days.
# sleep 2; ls -l //2秒後執行ls指令,如果是2分鐘後則單位要變成2m。
nohup指令介紹
SYNOPSISnohup COMMAND [ARG]...
nohup - run a command immune to hangups, with output to a non-tty //忽略SIGHUP信號,登出後指令執行不中斷
每15秒執行指令
# crontab -e
* * * * * /bin/sh /root/graduate.sh //0秒後執行
* * * * * sleep 15; /bin/sh /root/graduate.sh //15秒後執行
* * * * * sleep 30; /bin/sh /root/graduate.sh //30秒後執行
* * * * * sleep 45; /bin/sh /root/graduate.sh //45秒後執行
每1秒執行指令用使用迴圈方式在背景執行
# vim graduate.sh
#! /bin.sh
while true; do
/bin/sleep 1
/bin/date > time.txt
done
# nohup graduate.sh &
沒有留言:
張貼留言