Crontab error Cannot execute binary file.

Anyone can help me ?

I try to using crontab with a simple shell script as echo it run okay but now i have more command in script. when I set entry to crontab and whe it run i get mail with error cannot execute binary file.

it urgent so please help me the soutions. Thank so much for your help. :frowning:

Please post your crontab file text and the script text as well.

Even if I myself may not be able to solve your problem even after seeing those, but it will surely help anyone who is knowledgeable enough.

Also check that your script has execute permission .

Thank for your reply.

============This is content of crontab file ====================

19 2 * * * /etc/webmin/cron/tempdelete.pl
0 * * * * /etc/webmin/bandwidth/rotate.pl
0,10,20,30,40,50 * * * * sh /root/temp/testing/autoimport >> /root/temp/testing/errorlog

===================Script autoimport=======================

sh import Testfolder

My shell script below for import data to Oracle

it run okay. but the text display not correct follow order command executed.

=========================Shell Script import file=================

#!/bin/sh

#directory = ${1-'pwd'}

#run import data with SQLLoader
runSQLLoader()
{
/home/oracle/app/oracle/product/11.1.0/db_2/bin/sqlldr test/12345@orcl control=$1 bad=$2 log=$3 discard=$4 data=$5 direct=TRUE;
if [$? -ne 0]
then
return 1
else
return 0
fi
}

ARGS=1
filecontrol="ControlFile/test.ctl"

if [ $# -ne "$ARGS" ];
then
directory=`pwd`
else
directory=$1
fi

for file in $(find $directory -type f )
do
fname=`basename $file`

#display the file to miport data
echo "Excute importing file : $fname "

#asking user waiting for this job finish
echo "Please waiting for you look finished task"

errorfile="Error/$fname"
processedfile="Processed/$fname"
badfile="Processed/bad$fname"
discardfile="Processed/discard$fname"
logfile="Processed/log$fname"

#run function above
runSQLLoader $filecontrol $badfile $logfile $discardfile $file;
#get result of importing data if 1 have error or 0 it importing okay
if [$? -ne 0]
then
echo "Error ! Have an error happen during import data "
mv "$file" "$errorfile"
else
echo "Finish importing file : $fname"
mv "$file" "$processedfile"
fi
done | sort

exit 0
======================End Shell Script code=================

I has set chmod 777 to this file. I got e mail from cron have error like this :
/usr/bin/import: /usr/bin/import: cannot execute binary file.

I think, the name of my script file maybe similar with the system file.

I Has changed the file name to importdata and get this error sh: importdata No such file or directory.

Please I ask my problem when I run sheel script. If I run shell script from file name as importdata I got error Command not found.

But when I put sh in font of importdata it run okay ? Please explain for me more about this thing. Thank so much.

I am a newer. I try using the shell scritp only 3 day.

Thanks.

Existing :
sh import Testfolder

change to
sh <full_path>/import Testfolder

99% of problems with cron are that the environment is minimal and none of your profile is run. Basically you will be running as you, have $HOME setup and that's about it.

Hi Porter.

How do I config enviroment for my case. I run it when I login with root it run okay. I add that script to crontab it cannot run.

Please help me the solution or example. Thanks so much.