I'm looking to automated fsck on my FreeBSD server. I have an idea how to do this, but because it's running pretty powerful commands, I'd like some more eyes on it before I set it to run.
Step 1. Cron job.
My cron will look something like this: 0 17 * * 0 myfsckscript.sh > /usr/local/var/log/fscklog/$(date).log
, to run at 5PM every sunday. It will be run from root's crontab, because what I'm doing requires root permissions.
The script goes something like this:
init 1 # Run single-user mode, so fsck can run correctly
fsck -y # Run fsck
fsck -y # Run again, to clean up. Makes my machine act better
init 5 # bring it back up.
My main concerns follow:
I'm sorry this is mostly a confirmation question, but with my level of skill with sh I'm not comfortable setting this to run without someone more experienced taking a look first.
What about just add this to /etc/rc.conf:
fsck_y_enable="YES"
background_fsck="NO"
Basically, means to run fsck -y
and don't try to run in background, so depending on the size of your disks, this could take a while to finish.