Little Girl's Mostly Linux Blog

EggTimer


Egg Timer

This page was last updated on July 20, 2009.

Method 1

This is a command line method for creating a timer using the sleep command. The system bell will sound once at the beginning and once at the end of the count.

  • Open a terminal window and type this command, replacing NUMBER with the number of seconds you’d like the timer to run:
  • echo -e '\a' >&2; sleep NUMBER; echo -e '\a' >&2
    • For example, you would use this command to set a timer for 30 seconds:
    • echo -e '\a' >&2; sleep 30; echo -e '\a' >&2
  • To time minutes, hours, or days with this command, you need to add an m for minutes, an h for hours or a d for days after the NUMBER in the command.
    • For example, you would use this command to set a timer for 30 minutes:
    • echo -e '\a' >&2; sleep 30m; echo -e '\a' >&2

Method 2

This is a script that asks how long you’d like the timer to run, notifies you of each minute that passes and rings the system bell when the time is up.

  • The script:
  • #!/bin/bash
    echo -n "How many minutes would you like the timer to run? "
    read limit
    echo
    echo "Timing $limit minutes..."
    echo
    counter=0
    while [ $counter != $limit ]; do
       echo "$counter minutes so far...";
       sleep 60
       let "counter = $counter + 1"
    done
    if [ $counter = $limit ]; then
       echo
       echo "Time's up - $counter minutes have elapsed!"
       echo -e '\a' >&2
       exit 0
    fi
    
  • Save the script:

    1. Copy the above script.
    2. Paste it into a text editor.
    3. Save the file as timer.sh.

  • Run the script:

    1. Open a terminal window.
    2. Change to the directory the script is in.
    3. Type this command:
    4. bash timer.sh
    5. Press the Enter key.

  • What it looks like when it runs:
    How many minutes would you like the timer to run? 3
    
    Timing 3 minutes...
    
    0 minutes so far...
    1 minutes so far...
    2 minutes so far...
    
    Time's up - 3 minutes have elapsed!
    


    Obligatory Happy Ending

    And they all lived happily ever after. The end.

    Back to top

1 Comment »

  1. [...] The shell script is actually a modified version of the one published here (http://mostlylinux.wordpress.com/commandline/eggtimer/). [...]

    Pingback by Simple egg timer on Linux for Pomodoro technique « {love to code?} — December 19, 2010 @ 2:27 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: WordPress Classic. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.