Skip to main content

Thread: bash script acting different when run from terminal vs cron


hi all, maintain backup script company, can't work right when launched root's crontab. here's snip of code that's acting up:

code:
#!/bin/bash -v date=`date +%y-%m-%d` mavail=`df -m | grep dailybackup | tr -s ' ' | cut -f 4 -d ' '` echo "evaluating space available on backup drive..." >> /var/log/bkup_$date.log spacereq100=`more /etc/scripts/prevbkupsize` spacereq110=$(($spacereq100 * 11 /10)) echo "size of previous backup =                    $spacereq100 mb" >> /var/log/bkup_$date.log echo "space required tonight's backup (110%) = $spacereq110 mb" >> /var/log/bkup_$date.log echo "space available tonight's backup =       $mavail mb" >> /var/log/bkup_$date.log echo >> /var/log/bkup_$date.log if [ $mavail -gt $spacereq110 ];     echo "there enough space on backup drive.  continuing..." >> /var/log/bkup_$date.log   else     echo "making space on backup drive..." >> /var/log/bkup_$date.log   fi
here's log file output when run terminal ('sudo /etc/scripts/daily_bkup'):

code:
evaluating space available on backup drive... size of previous backup =                    98604 mb space required tonight's backup (110%) = 108464 mb space available tonight's backup =       181887 mb  there enough space on backup drive.  continuing...
here's output when ran root's crontab ('/etc/scripts/daily_bkup'):

code:
evaluating space available on backup drive... size of previous backup =                    :::::::::::::: /etc/scripts/prevbkupsize :::::::::::::: 99036 mb space required tonight's backup (110%) =  mb space available tonight's backup =       201048 mb  making space on backup drive...
anyone got thoughts? thanks!

try adding
code:
mailto=""
to top of crontab.


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] bash script acting different when run from terminal vs cron


Ubuntu

Comments

Popular posts from this blog

Warning, the Safe Path is not accessible vm3 - Joomla! Forum - community, help and support

uppercase letters in url - Joomla! Forum - community, help and support

Joomla! Update is not offering Joomla 3 - Joomla! Forum - community, help and support