![]() |
Sixerdoodle Electronics - FreeNAS FSCK cron |
|
|
Description
Are you running FreeNAS? Here's a quick little PHP script to run a fsck on all your defined mount points to make sure the file system is clean. Sends you an e-mail when/if it finds some problem. It does not automatically fix the problem since you may need to dismount and we probably don't want to do that automatically!. Uses the FreeNAS Email Reports configuration for it's SMTP info. YOu can still leave Email Reports disabled, just check the Enable box, fill in the SMTP data, then clear the check box. The Email reports configuration is still saved and usable even if the utility is itself is left disabled. I'm running off the LiveCD version of FreeNAS. Here's how I've got FSKtest configured on my system. You might want to do it differently! By the way, this also might give you some ideas on how to customize your FreeNAS system even though you're running the LiveCD variant. On one of my mounted disks, I've got a top level /custom/ directory created. It's actually at the top of one my of SMB mounted shares so that I can access it easily from my windows box in case I need to edit the script files. Unpack the zip file into the /custom/ directory. That gets the customized scripts into a place where I can edit them from my windows system. Now, to get the custom files to a place where FreeNAS can execute them, I set up a boot time copy command to copy the files from the SMB shared disk to the LiveCD RAM drive. This way your customization files survive a reboot, even though you're only running of a boot CD and RAM disk. Yeah, you probably could execute directly from the shared disk, but I might want to write a script some time that dismounts that shared disk! Stick a PostInit command script in FreeNAS like this. ie copy all the .php files from the /custom/ directory over to the local /etc/inc/ directory. That gets the script to a good executable place. Now don't forget to fill in your mail server info in the FreeNAS Email Report screen. Yes, you might have to check the enable box, fill out your info and then uncheck the enable. That's ok and should work fine. FSCKtest.php just needs to be scheduled to run periodically. Create a cron job something like this one that executes the fscktest.php script once a day at noon. Don't forget, reboot once so that PostInit command fires and moves the files to the /etc/inc directory, otherwise your cron job will fail!
This ZIP file contains the fscktest.php script as well as a TestEmail.php script to make sure you've got your e-mail configured correctly. Download it now from here. Talk about it here
|