Ken R. Posted December 21, 2010 Share Posted December 21, 2010 To close this out, the modified package would look like this: #UNMENU_RELEASE $Revision: 7 $ $Date: 2010-03-29 23:12:23 -0400 (Mon, 29 Mar 2010) $ PACKAGE_NAME Monthly Parity Check PACKAGE_DESCR This package installs a script that will schedule a monthly parity check on the 1st Tuesday of the month at 6:30AM. PACKAGE_DESCR <br>Use <b>NOCORRECT </b>if you do not want parity to be automatically updated. PACKAGE_DESCR <br>Use <b>CORRECT </b>if you do want it automatically updated.<br<br> PACKAGE_DESCR It is recommended that you <b>NOT</b> automatically correct parity, since it might be a data drive that is in error, PACKAGE_DESCR and the parity drive might be correct. <br>Challenge is determining which is correct, and which is in error. PACKAGE_DESCR unRAID normally assumes the data is correct and parity is wrong. Pressing the "Check" button on the web-interface PACKAGE_DESCR will check <b>AND</b> update parity based on the data disks. PACKAGE_URL none PACKAGE_FILE monthly_parity_check PACKAGE_INSTALLED /var/log/monthly_parity_check PACKAGE_DEPENDENCIES none PACKAGE_VARIABLE Parity Check Type (CORRECT/NOCORRECT)||vCHECK_TYPE=NOCORRECT||Use NOCORRECT if you do not want parity to be automatically updated,<br>CORRECT if you do want it automatically updated. PACKAGE_INSTALLATION #Version: 1.0a PACKAGE_INSTALLATION crontab -l >/tmp/crontab PACKAGE_INSTALLATION grep -q "/root/mdcmd check ${vCHECK_TYPE-NOCORRECT}" /tmp/crontab 1>/dev/null 2>&1 PACKAGE_INSTALLATION if [ "$?" = "1" ] PACKAGE_INSTALLATION then PACKAGE_INSTALLATION crontab -l | egrep -v "check parity on the first|/root/mdcmd check " >/tmp/crontab PACKAGE_INSTALLATION echo "# check parity on the first Tuesday of every month at 06:30am:" >>/tmp/crontab PACKAGE_INSTALLATION echo "30 06 1-7 * * [ \"\$(date '+%a')\" == \"Tue\" ] && /root/mdcmd check ${vCHECK_TYPE-NOCORRECT} 1>/dev/null 2>&1" >>/tmp/crontab PACKAGE_INSTALLATION cp /tmp/crontab /var/spool/cron/crontabs/root- PACKAGE_INSTALLATION crontab /tmp/crontab PACKAGE_INSTALLATION fi PACKAGE_INSTALLATION echo "Version: 1.0a ${vCHECK_TYPE-NOCORRECT}" > /var/log/monthly_parity_check PACKAGE_VERSION_TEST grep "Version:" /var/log/monthly_parity_check | awk '{print $2}' PACKAGE_VERSION_STRING 1.0a PACKAGE_MEMORY_USAGE Small If you name it "first-tuesday-parity-unmenu-package.conf" and put it in /boot/packages it will appear as its own separate package in the package manager. It is actually quite ingenious. It will invoke the cron entry every day at 6:30 AM on the 1st through the 7th of the month. On each day the test if the current day = "Tue" will be made. The actual parity check will only occur on the Tuesday when the date string is matched. Clever... Edit: Oh sh...t I accidentally edited the original post instead of quoting it... (Why is the "modify" adjacent to the "quote") I'll try to get back the old text... but not sure if possible. Probably in my cache. Sorry.... Joe L. Link to comment
Joe L. Posted December 22, 2010 Share Posted December 22, 2010 Yes, you can just edit the .auto_install file You are obviously not a beginner. Nice use of the "date" command to get the first "Tuesday" You'll need to invoke the .auto_install once on the command line, or reboot to get it to be invoked. Just don't click on the "Re-Install on Re-Boot" button on the monthly-parity-check package again, or it will overwrite your changes. Joe L. Link to comment
Ken R. Posted December 22, 2010 Author Share Posted December 22, 2010 No, I stole that from the code bank! heavens<g> Thank you. Link to comment
Ken R. Posted January 3, 2011 Author Share Posted January 3, 2011 Hello again. When using 'echo' and redirecting the output to a file, the date command executes no matter the quotes, how do I write what I want written to the file and not the result? ie: echo "[ "$(date '+%a')" == "Tue" ]" >/tmp/test result; [ Sun == Tue ] The desired result would be: [ "$(date '+%a')" == "Tue" ] Link to comment
Joe L. Posted January 3, 2011 Share Posted January 3, 2011 Hello again. When using 'echo' and redirecting the output to a file, the date command executes no matter the quotes, how do I write what I want written to the file and not the result? ie: echo "[ "$(date '+%a')" == "Tue" ]" >/tmp/test result; [ Sun == Tue ] The desired result would be: [ "$(date '+%a')" == "Tue" ] Try echo "[ \"\$(date '+%a')\" == \"Tue\" ]" >/tmp/test.sh You just need to back-slash escape the quotes and $ special characters. Joe L. Link to comment
Ken R. Posted January 4, 2011 Author Share Posted January 4, 2011 Just to let you know the cron job fired right on time - First Tuesday of the month. Thanks again. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.