Help in running SQL queries in linux script

November 24, 2010 at 05:53:41
Specs: Linux
I created a DB table named test and I tried using the below shell script to insert a row in the table.

sqlplus test/test@test <<ENDOFSQL

INSERT INTO test VALUES('test1',123,'test2','test3');

A row is succesfully inserted into the table when I run the script manually, but it does not insert rows when a cron job is scheduled.

Could you please help me with this?

Thanks in advance.


See More: Help in running SQL queries in linux script

Report •

November 24, 2010 at 12:03:04
Whenever a Unix/Linux script runs from the command line, but not from cron, it is because cron uses a different initial environment from the user. I suggest that you include yur user environmental variables in the script.

The most importatant one is the PATH variable. Also, include any variables that the database requires.

I also suggest that you inlucde the shell invocation, i.e. #!/bin/bash if you are using bash shell.

Report •
Related Solutions

Ask Question