September 9, 201015 yr Stupid question but what is the best way to insert a line to crontab from /boot/config/go script? I need to put a script to run each minute or two (for controlling fan speed) and /etc/cron.hourly is just too long. Thanks! # need the following to go to crontab from /boot/config/go */2 * * * * /boot/scripts/unraid-fan-speed.sh 1>/dev/null 2>&1
September 9, 201015 yr Stupid question but what is the best way to insert a line to crontab from /boot/config/go script? I need to put a script to run each minute or two (for controlling fan speed) and /etc/cron.hourly is just too long. Thanks! # need the following to go to crontab from /boot/config/go */2 * * * * /boot/scripts/unraid-fan-speed.sh 1>/dev/null 2>&1 I'd do it like this: chmod +x /usr/local/bin/unraid-fan-speed.sh crontab -l >/tmp/crontab grep -q "unraid-fan-speed.sh" /tmp/crontab 1>/dev/null 2>&1 if [ "$?" = "1" ] then crontab -l | egrep -v "control unRAID fan speed based on temperature:|unraid-fan-speed.sh" >/tmp/crontab echo "# control unRAID fan speed based on temperature:" >>/tmp/crontab echo "*/2 * * * * /usr/local/sbin/unraid-fan-speed.sh 1>/dev/null 2>&1" >>/tmp/crontab cp /tmp/crontab /var/spool/cron/crontabs/root- crontab /tmp/crontab fi In addition to adding the line to the new crontab, You must copy the new crontab file to /var/spool/cron/crontabs/root- (with a trailing "dash" on the end) since unRAID'd emhttp does not re-read the crontab if you make changes. It uses the file for its next starting point.
September 9, 201015 yr Author Joe, thanks. Is it any good to copy directly a saved version of crontab to /var/spool/cron/crontabs/root and root-
September 9, 201015 yr I don't think it's good form to just use a saved static copy of a file that by it's nature should be dynamic. With that said, on a rarely used environment you could likely get by without issue. Likewise in the future, if anything would change on the base unRAID distro or a new addon uses it, you might be spending time troubleshooting why something doesn't work unless you remember to double-check this overwrite.
September 9, 201015 yr Author With that said, on a rarely used environment you could likely get by without issue. Likewise in the future, if anything would change on the base unRAID distro or a new addon uses it, you might be spending time troubleshooting why something doesn't work unless you remember to double-check this overwrite. Very true, thanks again!
September 9, 201015 yr I don't think it's good form to just use a saved static copy of a file that by it's nature should be dynamic. With that said, on a rarely used environment you could likely get by without issue. Likewise in the future, if anything would change on the base unRAID distro or a new addon uses it, you might be spending time troubleshooting why something doesn't work unless you remember to double-check this overwrite. I agree. submit it as a "bug" to lime-tech. It is their brain-damaged handling of crontab when dealing with the "mover" script that causes the issue. They did not expect anybody else to be changing crontab. I do not use the saved copy of crontab, emhttp does. I always grab it dynamically using "crontab -l" Joe L.
Archived
This topic is now archived and is closed to further replies.