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