Unix script Problem with crontab


 
Thread Tools Search this Thread
Operating Systems Solaris Unix script Problem with crontab
# 1  
Old 01-15-2008
CPU & Memory Unix script Problem with crontab

Hi Experts,

Am facing some problems with script (Sun solaris 9). My script (sqlplus.sh)looks like this. . .

...............................................
set 'date'
dd=$3
export dd
mon=$2
export mon
yyyy=$6
export yyyy
cd /oracle/P47/saparch
LOG_FILE=/oracle/P47/saparch/archive_today_$yyyy$mon$dd.log
echo "*******************************************************************">> $LOG_FILE
date >> $LOG_FILE

sqlplus "/as sysdba"<< EOF >> $LOG_FILE
set serveroutput on ;
set time on ;
recover automatic standby database;
CANCEL
exit
EOF
echo "Finish applying archives in SAP DR site..." >> $LOG_FILE

echo " ----------------------------------------------------------">> $LOG_FILE

echo "End SAP DR script " >> $LOG_FILE
echo "=========================================================" >> $LOG_FILE

mailx -s "LOG - SAP DR applying archives $dd$mm$yy..." vrjalli@xyz.com < $LOG_FILE

...............................................................................................

My problems are
1. When I run manually (with command: sh sqlplus.sh) it is working fine. But when i schedule in cron it is not working.
2. Mails are not coming.
3. Log file is coming without date stamp.(archive_today_.log)

Please help. . .

rgds
# 2  
Old 01-15-2008
When you say its not working what is the error received ?

modify your cron entry to

Code:
script > logfile 2>&1

and instead of using just sqlplus
use the absolute path of the sqlplus as user's profile is not implicitly loaded to cron unless done explicitly
# 3  
Old 01-15-2008
Hi matrixmadhan,

Thanks for ur reply!!!!

my script parh is: /oracle/SID/saparch/sqlplus.sh

and cron entry is:
30 10,13,15,17,19,21 * * * /oracle/P47/saparch/sqlplus.sh

and I hv given 777 permisions to sqlplus.sh file.

rgds
# 4  
Old 01-15-2008
Ok. After using absolute pathname what is cron saying after executing ?

Post the error message if there are any such !
# 5  
Old 01-15-2008
Am not getting any error simply it is not executing. . . . .

my script parh is: /oracle/P47/saparch/sqlplus.sh
and cron entry is:
30 10,13,15,17,19,21 * * * /oracle/P47/saparch/sqlplus.sh

but when my pwd is: /oracle/P47/saparch
it is working with command: sh sqlplus.sh

rgds
# 6  
Old 01-15-2008
Hi Matrixmadhan,

Actually when i try ps -ef | grep

I recd message that there is a mail in /var/mail/root and the contents are as below

Date: Tue, 15 Jan 2008 17:31:00 +0530 (IST)
From: Super-User <root@ttmlpunesun>
Message-Id: <200801151201.m0FC10GB024886@ttmlpunesun>
To: root@ttmlpunesun
Subject: Output from "cron" command
MIME-Version: 1.0
Content-Type: text/plain
Content-Length: 148

Your "cron" job on ttmlpunesun
/oracle/P47/saparch/sqlplus.sh

produced the following output:

/oracle/P47/saparch/sqlplus.sh: sqlplus: not found
.................................................................................

rgds
# 7  
Old 01-15-2008
What the cron job mail is saying is that your script is not finding the sqlplus execuble

You need to modify the line

sqlplus "/as sysdba"

to include the full pathname to sqlplus.

It is always good practice to include full pathnames in all shell scripts invoked via cron.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Script problem when running on crontab

Hi guys! I created a backup script that works fine when I run manually, but when I put a crontab job to execute it the result are not the expected. (not a time problem). Here is my script: bash-3.00# cat /bk_tool/backup2.sh #!/usr/bin/csh clear set DIR_HOST='SCP08' ... (3 Replies)
Discussion started by: andredemartini
3 Replies

2. Shell Programming and Scripting

Execution of Unix script after every second without crontab

Hi, I have shell script "A" which is executing oracle pl/sql procedure and initiate its multiple threads at a time as below on given user value in an other script "B". I want to execute script "A" after every second with out cron tab as " A " will keep on executing after every second till... (1 Reply)
Discussion started by: saad.imran@gmai
1 Replies

3. UNIX for Dummies Questions & Answers

Problem with a script in crontab

Hi guys, I have a shell script which i have put on crontab to run every min. Problem is that is isn't running. But if i run the script from the existing location it runs perfectly. but if i got out of the directory and run it giving the path. it doesn't work. sh script_name.sh ----... (3 Replies)
Discussion started by: nick1982
3 Replies

4. Shell Programming and Scripting

Problem with perl script on crontab

Hi everybody, I have a perl script. I want to run it as a cron job every 10 minutes. I insert the command into crontab , using crontab -e. The problem is, I didnt get any output from script inside crontab, whereas when I run it manually through 'perl myscript.pl' it running well. Here is the cron... (2 Replies)
Discussion started by: franzramadhan
2 Replies

5. HP-UX

Problem with script arguments in crontab

I have a script scheduled in cron as shown below. 16 12 * * * /users/mydir/bin/process_master.ksh `date '+%Y%m%d'` >> /users/mydir/process_master.out This script executes correctly when invoked on command line, but doesn't work the same when scheduled in crontab. Crontab is working fine... (3 Replies)
Discussion started by: mk1216
3 Replies

6. Shell Programming and Scripting

Problem with crontab running a script

I am trying to use the CRON utility in Fedora 11 & CentOS... I intend to run a script which pops up a warning message every hour and i made the following entry using "CRONTAB -e " * * * * * sh /bin/myscript.sh But this does not seem to be running. Another thing to note is that,... (4 Replies)
Discussion started by: Vabiosis
4 Replies

7. Linux

Problem with crontab + bash script

Crontab: 16 14 * * * /root/bin/./empty_mail.sh >> /root/bin/log.txt L=`mailq |grep -c frozen` echo "${NUMMAIL} frozen mail to be removed from the mailq" #echo "Press Enter to continue" #read CONTINUE echo -en "-> " for i in `mailq | grep frozen | awk '{print $3}'` ; do exim4 -Mrm $i... (1 Reply)
Discussion started by: wessberg
1 Replies

8. UNIX for Dummies Questions & Answers

Variable problem in script when using crontab

Hi, this is my first shell script. Anyway i am trying to ftp files from one machine to another. The name of the script is ifsftp_orabkp. The code is as follows: HOST="122.122.122.22" USER="ftp_ftp" PASSWD="ftp.222222" Y1=`(perl -e '@y=localtime(time());printf... (11 Replies)
Discussion started by: dazz
11 Replies

9. Shell Programming and Scripting

problem running shell script (for oracle export) in crontab

Hello Gurus, I've been tasked with solving a problem at my new job and I'm stumped. We've got a script that dynamically builds an oracle export parameter files and then runs export from the shell. it runs fine when using the shell, but will NOT run (fails in one spot everytime) when entered... (1 Reply)
Discussion started by: jsheehan223
1 Replies

10. Shell Programming and Scripting

Problem with executing a script scheduled in crontab

Hi I have written a shell script(in Solaris) in which following logic is there..... i=1 while read control do key=`echo $control | awk -F$DELIMITOR '{ print $1 }'` echo "Key Values" ${key} i=`/usr/bin/expr $i + 1` done < $CONFPATH/$CONFFILE when i execute it at prompt it... (4 Replies)
Discussion started by: Amardeep
4 Replies
Login or Register to Ask a Question