LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   SUSE / openSUSE (https://www.linuxquestions.org/questions/suse-opensuse-60/)
-   -   Command would not execute within a script (https://www.linuxquestions.org/questions/suse-opensuse-60/command-would-not-execute-within-a-script-656145/)

pramka 07-16-2008 10:03 AM

Command would not execute within a script
 
Hi,
I wrote a script to display disk-quotas. It works fine if I execute it manually. However when I execute it from cron it says ...
"repquota: command not found"
day=`date +%a`
if [[ $day == "Sat" || $day = "Sun" ]]
then
echo Weekend job will not execute
fi
if [ $day == "Wed" ]
then
repquota -av > /var/log/quota.log
repquota -avg >> /var/log/quota.log
else
echo Job not scheduled for today
fi
mailx -s "Result of Quotacheck" root@localhost << EOT
"`cat /var/log/quota.log`"
EOT
Also there is no display in the body of the mail only ... ""

csinclair 07-16-2008 10:10 AM

repquota path info..
 
Try putting the full path to the executable repquota in the cron script, it's probably unable to find it's parent directory in the $PATH variable.

Craig

gparrish 07-16-2008 10:11 AM

The problem is the environment. It can not find the script due to the $PATH. Basically it does not know where the script lives. Add to the script a "env" or "set" statement and dump that to a file and you can compare that env to your environment from your shell/CLI.

The likely fix will be to just specify the full path to the script or to add a path statement to the top of the script. You many need to export the path also but some basic testing will let you know if that is needed.


All times are GMT -5. The time now is 10:00 PM.