Cannot create a directory

Hi,
I am using the following command to check weather directory exists , if not i am creating a directory.

if [ -d /apps/cron/healthcheck.log ]
then
   echo "directory already exsist"
else
   mkdir healthcheck.log
   echo "directory  created" >>  $_LOGFILE
fi

But i am gettin the following error in /var/spool/mail/root

mkdir: cannot create directory `healthcheck.log': File exists

can someone help me?

Thanks,
ahamed

The file exists, but it's file, not a directory. You are maching it with "-d" instead of "-e".

even after changing it to -e still getting the same error..
is there any other command to check for directory exist and create it if now..

What is the name of the directory?

/apps/cron
OR
/apps/cron/healthcheck.log

And..

What is the value of $_LOGFILE ?

And..
There is evidence that the script is running from cron.
Because the mkdir statement does not contain a full path it has probably created a directory called:
/healthcheck.log
on a previous run. Therefore it still exists.

If we guess that the intention is to create a directory called /apps/cron/healthcheck.log the script needs the full pathname.

if [ -d /apps/cron/healthcheck.log ]
then
   echo "directory already exists"
else
   mkdir /apps/cron/healthcheck.log
   echo "directory  created" >>  $_LOGFILE
fi

The value in $_LOGFILE will need to be a full pathname too. The environment for cron is not the same as the user environment.

the directory name is healthcheck.log. since i want the directory to be created in /apps/cron/ i am appending the exact location.

$_LOGFILE is a log file which i have given the entire path in user defined variable for easy access

There might be a non-directory there already preventing a directory with that name being created. ls -l /apps/cron/healthcheck.log

Thanks guys..
Now its working fine