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
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.
#!/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:
- Copy the above script.
- Paste it into a text editor.
- Save the file as timer.sh.
Run the script:
- Open a terminal window.
- Change to the directory the script is in.
Type this command:
- 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!
Alternative to system beep
If the system beep doesn’t work for you (mine currently doesn’t, and that could be that I didn’t wire my motherboard correctly or that Kubuntu no longer uses the same command(s) to trigger the beep), you can replace echo -e ‘\a’ >&2 with paplay /path/to/soundfile.ogg or paplay /path/to/soundfile.wav (replacing the path and file name with your path and file name) to use the PulseAudio sound player in the commands and scripts above.
Obligatory Happy Ending
And they all lived happily ever after. The end.