Hi,
I have used crontab to do this, but lately I have moved to use incron. I will explain both examples as precisely as I can:
With cron, I added this to /etc/crontab
*/30 * * * * your_username beet import -iql /path/to/logfile.log /path/to/downloaded/music
*/30 means it runs every thirty minutes
-i = incremental, skips folders already scanned
-q = quiet, no input required
-l = logfile
Which worked great. As I would like to have a little more details in the log file than beet can provide at the moment, I wrote this little script with a little help from friends!:
#!/bin/bash
log=/path/to/logfile.log
echo "">>$log
echo "------------ beet-auto-import.sh ---------------">>$log
beet import -iql /path/to/logfile.log /path/to/downloaded/music >>$log 2>&1
echo "Finished: $(date)">>$log
echo "-------------------------------------------------------">>$log
Saved as beet-auto-import.sh, put in my users bin/-dir. Chmod +x beet-auto-import.sh
The "2>&1" redirects more output from the beet-command to the logfile.
All the echo-stuff is to make the log-file more readable for myself, and adding the date and time for when beet is finished is just a product of my obsessive compulsive disorder.
Not included in the example: My script also tells my logitech media server to rescan it's library to discover the newly imported music. I also tried to add a command that deleted leftover directories (under 1 mb) but it did not quite work out and deleted full directories as well. For now I clean up manually.
INOTIFY/INCRONTAB METHOD:
Inotify monitors directories for changes - I would rather have the beet-auto-import-rescan.sh script to run only when needed, instead of cluttering my logfile! For an introduction and some examples, check
http://www.cyberciti.biz/faq/linux-inotify-examples-to-replicate-directories/ . It is actually quite easy, or at least it was on my headless debian wheezy 64bit box.
I will also tell you something about my setup, as I guess it will have some impact on how you have to tweak your incrontab. I use rtorrent with pyroscope, and rutorrent as a web gui for managing my torrent downloads. I have set up rtcontrol (part of pyroscope) to move completed torrents based on their LABEL as set in rutorrent (his was a bit tricky to achieve, but the details are not important for now). This happens from a regular cron job every 15 minutes. Torrents with no label wont be moved. This way I (and others in my not-so-technical family) can add torrents for download, and then label them in rutorrent if/when they feel like it. The rtcontrol cron job will move the downloaded AND labeled torrents to a comfortable hierarchy (/path/to/rtorrent/done/LABEL), and make sure the torrent continue to seed.
The torrents labeled MUSIC I want to import with beet, something which sometimes require renaming, retagging etc. Therefore I have set up incrontab to HARDLINK all files that ends up in /path/to/rtorrent/done/MUSIC to /path/to/rtorrent/done/MUSIC/process. Since it is a hardlink it wont take up extra space, and I can mess with the files as much as I like.
Here is my story:
1. Installed incron ("sudo apt-get install incron" as far as I remember)
2. Added my username in /etc/incron.allow (it contains nothing else)
3. Ran incrontab -e as my user and made it look like this:
/path/to/rtorrent/done/MUSIC IN_MOVED_TO cp -rpl $@/$# $@/process/
/path/to/rtorrent/done/MUSIC/process IN_CREATE,IN_NO_LOOP /home/user/bin/beet-auto-import.sh
$@ = path
$# = file
IN_MOVED_TO is needed because of the behavior of the aforementioned rtcontrol cronjob (which calls rtmv, which moves the downloaded files and symlinks them to their original location).
IN_NO_LOOP is needed not to spawn multiple instances of the beet-auto-import.sh script. I know it is possible to achieve this in other ways, but this was how I did it.
You will have to experiment with this based on your setup.
Now just "sudo tail -f /var/log/syslog" (on debian wheezy mind you) and "tail -f /path/to/beet/logfile.log" and see if things work.
Good luck! Truly a long read, I am not overly experienced in giving short and consistent advice.