MEHMET BALiOGLU

How to Fix “sqlldr: not found” Problem

I was trying to set a cron job which would load a Pandas dataframe to Oracle table once in an hour. When I run the Python code, the code works without any issues, however when I set the cron job it threw the following error.

/bin/sh: 1: sqlldr: not found

The problem stems from the fact that when you are logged on as a Linux user, the Linux system runs the .profile file which contains your PATH variables. However, the cron utility does not follow the same method. That’s why your .profile file is not executed when you are trying to run an application from cron.

In order to overcome this problem, you need to run your application from a bash file and this bash file should call the .profile before proceeding to run your original application.

Step 1: Add PATH variables to Bash Profile

export PATH="$PATH:/opt/oracle/instantclient_21_4"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/oracle/instantclient_21_4"

Step 2: Create the Bash File

#! /bin/sh
. $HOME/.bash_profile
sudo /usr/bin/python3 /root/bnnc/squeeze_to_oracle.py 

Now you can set the cron scheduler to run the .sh file. SQL Loader should smoothly work now.