문제

This is my current command to poll Yahoo! every two minutes for various stock prices and stick them on my old PowerBook's root window using the GeekTool pref pane...Apple for example:

echo 'AAPL: '; curl -s 'http://download.finance.yahoo.com.d/quotes.csv?s=aapl&f=l1' > .aapl.stock.txt; cat .aapl.stock.txt

What I would like to ask of UNIX literates is how to only poll Yahoo! between 9:30 am and 4:00 pm.

After trading hours every two minutes I'm asking these poor Yahoo! computers for a value that never changes! Help!

도움이 되었습니까?

해결책

You can exit or otherwise stop execution outside your target interval:

# Get current hours and minutes.
h=$(date +%H) m=$(date +%m)

# If it's less than 9:30, exit
[[ $h -lt 9 || $h -eq 9 && $m -le 30 ]] && exit 1

# If it's after 4, exit
[[ $h -ge 16 ]] && exit 1

yourcommand
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top