Automate Your Life With Cron

Example 3: Taming Your Music Collection Scenario

Every week on Tuesday, we browse local record shops to check if our favorite music artists have released anything new. When we find something we like, we throw down some cash monies and eagerly rush it home to rip to our computer and put on our MP3 player. We like our MP3 collection to follow a specific format and we definitely need the album artwork. In the past, I wrote a 4-part series on taming your music collection and we plan to utilize that taming script to keep our collection in line. However, with all the new albums we bring home each week, the time we spend running the script is quickly adding up.


We can solve this problem by periodically running the script on our ripped music directory, which would format it, add the album artwork we desire, and move it to the proper location. We have learned that doing things manually is a waste of time so let's utilize Cron to do this work for us! We'll set up a Cron job to run every Tuesday night at 10:00 PM, as we should be done ripping our new albums by then.

0 22 * * 2  ben  /home/ben/ -d /UntamedMusic/ -o /Music/ \;

We know from the Using Cron page that the date and time elements are telling Cron to schedule this job at the 0 minute of the 22nd hour on the 2nd day of each week (in orther words, every Tuesday night at 10:00 PM). Then, the second element tells Cron to run the command as ben. Finally, the last element tells Cron the command we'd like to run — our music taming script.

Now, every Tuesday, we can simply rip our music to our computer and go to sleep knowing we'll wake up to it properly formatted with the album artwork we so desire. And the best part is, we barely had to lift a finger!