So I created a small little script to check my media files every 30 minutes to make sure Madsonic can still access them. If it can't access them, it sends me an email to let me know.
The script comes in a couple parts, and this version of the script only works with Linux (although it can be made to work with Windows fairly easily.)
The first part is to create the script that actually checks for a file:
I created a file called /etc/checkmusic.sh
Code: Select all
#!/bin/bash FILE=$1 if [ -f $FILE ]; then echo "File '$FILE' Exists" else mail -s "Unable to find Media Files" email@example.com </dev/null fi
Part 2 of my script is to create the file to check for and place it somewhere in your media collection. My folder format is basically:
so I put a 0-byte text file under /media and I check for that.
The third part of the script is to check every 30 mins (or however often you want).
Run "crontab -e" as root to open the cron file.
enter "0,30 * * * * /etc/checkmusic.sh /media/filename.txt" (without quotes) and then save the file.
This will run the script at the top and bottom of every hour (ie. x:00 and x:30). You can specify more or less often as needed.
Be sure your system can already send email!!! You can test this by running the "mail -s" line from the script file from the command line. If you receive an email, you're good to go. If not, you will need to setup Sendmail or another application to send mail.
In the future, I may include a body to the email message with instructions on what to check for, or how to get Madsonic to be able to access my media files again. In this instance, my server (host machine) had rebooted and the NFS exports never got exported again because the NFS service wasn't configured to start at boot. This has been fixed, so I don't see issues in the future, but I have this precaution just in case....