Problem with my script
by TravisBrooker from LinuxQuestions.org on (#5FF4F)
Hi all,
there is my script,
#!/bin/bash
#!/bin/sh
. /home/dd/.sshConPrfl
WORK_DIR="directory; export WORK_DIR
SPOOL_DIR="directory"; export SPOOL_DIR
LOG_DIR=directory; export LOG_DIR
scr_name=scr
file_ext=txt
TODAY=`date +"%Y%m%d"`
LOG_DATE=`date +"%Y%m%d%H%M%S"`
sqlplus "my connection" @$WORK_DIR/mytest.sql $SPOOL_DIR/$scr_name"_"$TODAY".tmp"
$WORK_DIR > $LOG_DIR/$scr_name"_"$TODAY.log 2>&1
mv $SPOOL_DIR/$scr_name"_"$TODAY".tmp" $SPOOL_DIR/$scr_name"_"$TODAY"."$file_ext
when i run it in crontab, i saw the error below;
myscript.sh: line 29: sqlplus: command not found
mv: cannot stat /20210317.tmp': No such file or directory
but it works fine when i am running it with nohup. what could be the reason about why this script is not working with crontab? i checked the permissions and it seems fine. do you have any idea?
thannk you in advance.


there is my script,
#!/bin/bash
#!/bin/sh
. /home/dd/.sshConPrfl
WORK_DIR="directory; export WORK_DIR
SPOOL_DIR="directory"; export SPOOL_DIR
LOG_DIR=directory; export LOG_DIR
scr_name=scr
file_ext=txt
TODAY=`date +"%Y%m%d"`
LOG_DATE=`date +"%Y%m%d%H%M%S"`
sqlplus "my connection" @$WORK_DIR/mytest.sql $SPOOL_DIR/$scr_name"_"$TODAY".tmp"
$WORK_DIR > $LOG_DIR/$scr_name"_"$TODAY.log 2>&1
mv $SPOOL_DIR/$scr_name"_"$TODAY".tmp" $SPOOL_DIR/$scr_name"_"$TODAY"."$file_ext
when i run it in crontab, i saw the error below;
myscript.sh: line 29: sqlplus: command not found
mv: cannot stat /20210317.tmp': No such file or directory
but it works fine when i am running it with nohup. what could be the reason about why this script is not working with crontab? i checked the permissions and it seems fine. do you have any idea?
thannk you in advance.