Cron job not executing

I need to add 10 records to database from a file /tmp/authlist.log(contains insert into table sql commands)

When i execute the following script manually its executing and working fine.
the same is not getting executed when i try to execute using crontab

vi /tmp/test1.sh

#!/bin/sh
logfile=/tmp/authlist.log
mysqlauth=/tmp/mysqlauth.log
rm -rf $mysqlauth 1> /dev/null 2>&1
touch $mysqlauth
head -5 $logfile > $mysqlauth
#sed -i '1,5d' $logfile > logfile
exec < $mysqlauth
while read line
do
mysql -uroot -ppassword kalyan -e "$line"
done
crontab -e -u root
42 3 * * * root /tmp/test1.sh
[root@localhost ~]# crontab -l -u root
42 3 * * * root /tmp/test1.sh

Please let me know where i have committed mistake

Check the permission of the script . The script should have executable permission.

The script has 755 permission

-rwxr-xr-x 1 root root 270 2011-02-21 03:36 test1.sh

My guess is that your probably not finding mysql or something you need
that's called in your script.

Try changing your crontab entry to something like this to set what
you need in order to execute your script.

20 20 * * 6 SHELL=/usr/bin/ksh; export SHELL; . $HOME/.profile; /tmp/script.ksh > /tmp/script.out 2>&1

I would also place a "set -x" in your script to see where its failing. The
script execution path will than be placed in /tmp/script.out and that may
give you a clue to what's going on.

I think you have your cron entry incorrect:-

crontab -l -u root 
42 3 * * * root /tmp/test1.sh  

This states that at 03:42 every day, the following command is run:

root /tmp/test1.sh

so unless you have a command called root then this will fail to even start. If you are expecting this to nominate the user to run the command, then that is set by the fact that it is in root's crontab file.

Does this help?

Robin
Liverpool/Blackburn
UK