Beruflich Dokumente
Kultur Dokumente
https://unix.stackexchange.com/questions/23557...
Unix & Linux Stack Exchange works best with JavaScript enabled
sign up
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like
operating systems.. It's 100% free, no registration required.
log in
tour
help
Timer in bash script not accurate when using it with longer times
#!/bin/bash
# get user input
ZENITY1=$(zenity --entry --text '
1m:
60s\n
5m:
300s\n10m:
600s\n15m:
"Timer")
# put starting date in variable
STARTTIME=$(date)
# audit/check user input
WAITINGTIME=$(echo $ZENITY1 | egrep "[0-9]{1,}" -o)
if [ "$WAITINGTIME" == "" ]; then exit 1; fi
# main stopwatch
for i in `seq $WAITINGTIME -1 1`; do echo $i | osd_cat -A left -p top -i 100 -c
black -d 1; done
# time expired message
zenity --info --text="Time expired@\n$(date)\n\nStarted@\n$STARTTIME"
So this is the script that I have on my desktop. If I need to warn somebody for e.x.: "please warn me after 15 minutes". But if I use it in a
longer time, e.x.: 12 hours it's not very accurate! it could get ~10 minutes dierence to the real time... :\ Why is it?
/ bash
/ shell-script
26
58
24
101
213
1 Answer
If you nd it takes consistently too long, I guess you're seeing the overhead of fourty-odd
thousand executions of echo and osd_cat .
answered Oct 29 '11 at 18:24
Ulrich Schwarz
3,864
1 din 1
27
13.12.2014 19:15