I wrote a pretty sweet script tonight. It parallelizes the getmail retrieval process, while still printing prefixes so I know which accounts download which messages. This means that instead of my mail fetching process taking sum(i1,…,in), where i is the length of time for a given mail retrieval, my fetching process now takes max(i1,…,in).
#!/bin/sh
GETMAIL='python2.3 -Wignore /usr/bin/getmail'
unwanted() {
grep -E -v '(Copyright|getmail|Simple)';
}
echo "N-WAY GETMAIL RETRIEVER SCRIPT:"
$GETMAIL \
--rcfile=/etc/getmail/account1 \
2>&1 | sed -e \
's/.*/account1................: &/g' \
| unwanted &
$GETMAIL \
--rcfile=/etc/getmail/account2 \
2>&1 | sed -e \
's/.*/account2................: &/g' \
| unwanted &
...
$GETMAIL \
--rcfile=/etc/getmail/accountN \
2>&1 | sed -e \
's/.*/accountN................: &/g' \
| unwanted &
wait
Your script might be shorter and even more readable if you used GNU Parallel.
Watch the intro video to learn more: http://www.youtube.com/watch?v=OpaiGYxkSuQ