Productive Linux


 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Don't have an account?
Sign up to
Forgot your password?

1 December 2006 @ 23:11 GMT
by Paul

I searched high and low for a stopwatch that I could run on my laptop. Computers aren't the most accurate time pieces, it's true, but I didn't care. My task wasn't going to require any sort of accuracy.

Well, I couldn't find one. In fact the closest thing I found was the project management tool gnotime. This wasn't quite what I was looking for.

So, I wrote my own. The resolution is only in seconds and it's not very pretty. It suited my purpose though:


BEGIN=$(date +%s)
while true; do
    NOW=$(date +%s)
    let DIFF=$(($NOW - $BEGIN))
    let MINS=$(($DIFF / 60))
    let SECS=$(($DIFF % 60))
    echo Time elapsed: $MINS:`printf %02d $SECS`

Posted by Guest User on 2007-12-31 08:36:22.

Cute idea.

I made two potentially useful changes, one functional, one aesthetic:

Functional - insert: usleep 10000 the top of the loop to reduces update frequency from *very* fast to once every 100th of a second (massive reduction in CPU/power use)

Aesthetic - replace the echo command with: printf "\rTime elapsed: %d:%02d" $MINS $SECS avoid scrolling.

Posted by Daniel Thompson on 2008-11-11 13:38:04.

this doesent work

Posted by hi on 2009-05-18 10:14:15.
Comments disabled