I wrote a shell script that runs a couple of SQL queries (Oracle 11g), which in turn create a couple of *.csv files for later processing.
The script runs flawlessly if I execute it from the command line by hand.
So I tried to run it using cron:
53 15 * * * /home/me/ira_reports/ira.sh P firstname.lastname@example.org
As you can see, I included the full path to the script, along with the 2 arguments that it requires (in this example, "P" and "email@example.com".
I even added those 3 directories to cron's environment variable PATH
, which is where all the executables called in my script are located, especifically:
me@mybox /home/me/ira_reports:which sql
And I keep getting this error:
/opt/das/common/util/sql: line 37: /sqlplus.log: Permission denied
/opt/das/common/util/sql: line 39: sqlplus: command not found
/opt/das/common/util/sql: line 45: /sqlplus.log: Permission denied
I am not calling sqlplus in my script. Just plain sql exactly the way I do it from the command line.
FYI, in my script I source the *.sql files to the sql
command like this (full path as well):
sql @/home/me/ira_reports/stkcnt.sql <<EOF
Needless to say, none of the sql queries get executed.
Unfortunately, I do not have the possibility to run these queries with an user with escalated privileges. But I don't think I'd need to anyway, considering that cron technically runs with the same privileges of the user who set up the crontab file, and as I said, I can run the script from the command line without any issues whatsoever.
Please feel free to correct me.
Any hints or ideas will be more than welcome. Thanks in advance!