OT: Linux Alarm Clock Suggestions?
nivok
ulist at gs1.ubuntuforums.org
Wed Jul 6 15:06:24 UTC 2005
*Cron mp3 Alarm Clock*
Pre requirements:
- cron
- bash
- find
- mplayer
mplayer will probably the only one you need to get, it's available
'here' (http://www.mplayerhq.hu/homepage/design7/dload.html) (I
compiled/installed from source I believe, it wasn't super hard just
follow the instructions)
*Step 1:*
-In terminal:-
Code:
--------------------
crontab -l
--------------------
mine for example:
Code:
--------------------
sbolende at linuxbartonator:/etc$ crontab -l
no crontab for sbolende
sbolende at linuxbartonator:/etc$
--------------------
thus I have nothing scheduled but I DO have access to crontab
*Step 2:*
-In terminal:-
Code:
--------------------
find -/path/to/search/- -name "*.-ext-" -print >>-/path/to/playlist/file-
--------------------
mine for example:
Code:
--------------------
find /mnt/Public/Music\ Library/ -name "*.mp3" -print >>~/.playlist
--------------------
-/path/to/search/- = /mnt/Public/Music\ Library/ (this is where I keep
my iTunes on a samba share)
-ext- = mp3 (because I want to find mp3 files
-/path/to/playlist/file- = ~/.playlist. This where I want to save the
.playlist file, in my case I wanted it in ~/ (my home path)-- the
period infront is there simply to make it hidden (not klutter up my
home folder
*Step 3:*
in your favorite editor (I prefer vi) create a file and save as "alarm"
in ~/ with this content:!/bin/sh
Code:
--------------------
#!/bin/sh
mplayer -really-quiet -shuffle -playlist ~/.playlist
--------------------
-then, In terminal:-
chmod 700 ~/alarm
(this makes it read/write/_execute_)...the #!/bin/sh tells it to run it
as a terminal command
now to test it, type
Code:
--------------------
~/alarm
--------------------
(press q to stop it)
STEP 4:
-In terminal:-
Code:
--------------------
crontab -e
--------------------
(this launched joe for me -- have to ctrl+o then ctrl+x to
write/quit)
I then entered my scedule:
Code:
--------------------
30 13 * * 1-5 ~/alarm
--------------------
This is the guts to telling cron what you want it to do. So what does
all the above gibberish actually mean? A crontab entry consist of seven
fields separated by spaces. Each field is detailed below
- minuteThis controls what minute of the hour the command will run
on, and is between 0 and 59
- hourThis controls what hour the command will run on, and is
specified in the 24 hour clock, values must be between 0 and 23 (0 is
midnight)
- domThis is the Day of Month, that you want the command run on,
e.g. to run a command on the 19th of each month, the dom would be
19.
- monthThis is the month a specified command will run on, it may be
specified numerically (0-12), or as the name of the month (e.g. May)
- dowThis is the Day of Week that you want a command to be run on,
it can also be numeric (0-7) or as the name of the day (e.g. sun).
- cmdThis is the command that you want run. This field may contain
multiple words or spaces.
So, this crontab entry executes the command alarm at 1330 (1:30p.m.)
every day of every month that falls on Monday through Friday. (I have
to be at work for 4pm)
This was adapted from
http://grimthing.com/archives/2004/01/23/cron-mp3-alarm-clock/ for use
with ubuntu, hope this is useful or actually works for some of you
cheers
--
nivok
More information about the ubuntu-users
mailing list