Cron Alarm Clock


I only found
one GUI alarm/timer in portage and it wasn’t exactly what I was looking
for (see wmtimer below) so I decided just to use cron.

Cron is a good solution for an alarm – it’s running all the time and
simple to setup. Once I learned to use it, I use it all the time.

The crontab application is used to work with cron jobs. The cron
daemon checks for cronjobs every minute. A command line mp3 player can
be used here but I use Audacious. Cron will need to be told what X
display to use for Audacious to play. Discover the current display by:
env | grep DISPLAY

Then as regular user edit crontab.
crontab -e

Here’s a simple comment to represent the cronjob layout:
# minute (0-59),
# | hour (0-23),
# | | day of the month (1-31),
# | | | month of the year (1-12),
# | | | | day of the week (0-6 with 0=Sunday).
# | | | | | commands

Enter the time (multiple times, days need to be separated with
commas) and script to execute for the alarm. The asterik can be used
(*) to satisfy all variables. Here’s mine for audacious:
07 21 * * 1,2,3,4,5 env DISPLAY=:0.0 audacious /home/user/My\ Music/Other/Alarms/301gq.mp3

I found some good alarm tracks at this site the were perfect for the task.

I like vim as my system editor but any can be used. In Gentoo edit the /etc/rc.conf to change it. To list the crontab.
crontab -l

Additional Information:
Gentoo Cron Guide
Ubuntu Wiki on Cron
gnome-schedule is a GUI utility for Gnome – in sunrise overlay.
A Gnome/python alarm clock


Wmtimer works just fine for Gnome users (KDE has kalarm) it leaves a
small window on the screen which can’t be hidden but it is able use the
system beep or execute a command on an alarm/timer event. Starting it
from the command line is pretty easy:
wmtimer -a -t 18:39:00 -e "mpg321 ~/Music/Other/Alarms/301gq.wav"

Update:Audacious also has alarm ability but it’s
buried deep in it’s preferences ( Preferences > Plugins > General
), I find using cron better.

Author: WladyX on 21 January, 2008
Category: General, Scripts

Leave a Reply

Last articles