Home » Infrastructure » Unix » Unable to initiate crontab Job (10g, 10.2.0.1, AIX)
Unable to initiate crontab Job [message #623406] Wed, 10 September 2014 01:25 Go to next message
ashishkumarmahanta80
Messages: 231
Registered: October 2006
Location: kolkatta
Senior Member
Dear All,

I have scheduled the backup job on crontab. But is unable to execute. When i tried to execute it manually, it works.
I scheduled the job at 17:57 for 18:01
Below are the details -

$ crontab -l
01 18 * * * /oracledb1/DP_DIR_FIJIPROD/backup_database_expdp.sh
$ cd /oracledb1/DP_DIR_FIJIPROD/
$ ls -ltr
total 8
-rw-r--r--    1 oracle   oinstall        953 Aug 28 20:03 backup_database_expdp.sh
-rw-r--r--    1 oracle   oinstall          0 Aug 30 03:00 backup_error.log
$ sh backup_database_expdp.sh
The export started at Wed Sep 10 18:13:43 NZST 2014

Export: Release 10.2.0.1.0 - 64bit Production on Wednesday, 10 September, 2014 18:13:43

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Starting "SYSTEM"."SYS_EXPORT_FULL_04":  userid=system/******** DIRECTORY=DP_DIR DUMPFILE=EXPDP_FIJIPROD_100914_18_13.dmp LOGFILE=EXPDP_FIJIPROD_100914_18_13.log FULL=Y
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
^C
Export> stop
Are you sure you wish to stop this job ([yes]/no): yes



What could be the reason behind it?

Re: Unable to initiate crontab Job [message #623411 is a reply to message #623406] Wed, 10 September 2014 02:43 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Note that "But is unable to execute" does not help in any way to know what is the problem. Don't you think you should describe what you mean by "is unable to execute"?

And don't you think you should post your script or do you expect we debug it without knowing its content?

I bet you don't call/source your profile (.profile, .bashrc... or the like depending on your shell) in your script.

Re: Unable to initiate crontab Job [message #623485 is a reply to message #623411] Wed, 10 September 2014 09:51 Go to previous messageGo to next message
gazzag
Messages: 1118
Registered: November 2010
Location: Bedwas, UK
Senior Member
As Michel suggests, add a line to the beginning of your script similar to this, depending on your shell:
. /home/oracle/.profile | /home/oracle/.bash_profile  

Note the dot-space (". ") preceeds the profile script name to set your environment in the current shell i.e. your script run by cron.

HTH
-g
Re: Unable to initiate crontab Job [message #623505 is a reply to message #623485] Thu, 11 September 2014 00:12 Go to previous messageGo to next message
ashishkumarmahanta80
Messages: 231
Registered: October 2006
Location: kolkatta
Senior Member
Dear Michel,

I know what you told. Same set-up has done on another AIX server and it is working. Below are the script, which i wrote for the backup.

ORACLE_SID=FIJIPROD; export ORACLE_SID
ORACLE_BASE=/oracledb/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/OraHome_1; export ORACLE_HOME
LIB_PATH=$ORACLE_HOME/lib; export LIB_PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
export LD_LIBRARY_PATH
PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin:$ORACLE_HOME/bin
export PATH

#OUTPUT THE LOG TO A FILE
echo "The export started at `date`" > $EXPORT_LOG
exec >> $EXPORT_LOG 2>>$EXPORT_LOG 1>>$EXPORT_LOG

#ACTUAL EXPORT STARTS NOW
expdp userid=system/oracle DIRECTORY=DP_DIR DUMPFILE=EXPDP_FIJIPROD_`date +"%d%m%y_%H_%M"`.dmp LOGFILE=EXPDP_FIJIPROD_`date +"%d%m%y_%H_%M"`.log FULL=Y
if [ `echo $?` -ne 0 ]; then
echo "The export failed at `date`" >> $EXPORT_LOG
else
echo
echo "The export succeeded at `date`" >> $EXPORT_LOG
find -name "*.log" -mtime +3 -exec rm {} \;
find -name "*.dmp.gz" -mtime +3 -exec rm {} \;
fi
gzip /oracledb1/DP_DIR_FIJIPROD/EXPDP_FIJIPROD_`date +"%d%m%y*"`.dmp


I will update the same in my script, what gazzag has replied. Will revert after that...
Access to remote production server is less. SO, reply is delay.

Regards,
Ashish kUmar Mahanta
Re: Unable to initiate crontab Job [message #623508 is a reply to message #623505] Thu, 11 September 2014 00:57 Go to previous messageGo to next message
ashishkumarmahanta80
Messages: 231
Registered: October 2006
Location: kolkatta
Senior Member
Dear Michel,

Profile on the server are as below -

PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/lbin:/oracledb/app/oracle/OraHome_1/bin:.

export PATH

if [ -s "$MAIL" ]           # This is at Shell startup.  In normal
then echo "$MAILMSG"        # operation, the Shell checks
fi                          # periodically.
#echo "executing this profile stage 9"
#DISPLAY=192.168.0.152:0; export DISPLAY
echo "executing this profile stage 0"
AIXTHREAD_SCOPE=S; export AIXTHREAD_SCOPE
TEMP=/tmp
TMPDIR=/tmp
export TEMP TMPDIR
#echo "executing this profile stage 1"
ORACLE_BASE=/oracledb/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/OraHome_1; export ORACLE_HOME
LIB_PATH=$ORACLE_HOME/lib; export LIB_PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
export LD_LIBRARY_PATH
ORACLE_SID=FIJIPROD
export ORACLE_SID
#unset ORACLE_HOME
#unset TNS_ADMIN
export AIXTHREAD_SCOPE=S
umask 022


based on it I have made changes on my backup script -

PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/lbin:/oracledb/app/oracle/OraHome_1/bin:.
export PATH
ORACLE_BASE=/oracledb/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/OraHome_1; export ORACLE_HOME
LIB_PATH=$ORACLE_HOME/lib; export LIB_PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
export LD_LIBRARY_PATH
ORACLE_SID=FIJIPROD
export ORACLE_SID
export DMP_DEST=/oracledb1/DP_DIR_FIJIPROD
export DMP_RETENTION=3
expdp system/oracle directory=DP_DIR dumpfile=expdp_`date +%d%m%y_%H_%M`_$ORACLE_SID.dmp LOGFILE=expdp_`date +%d%m%y_%H_%M`_$ORACLE_SID.log full=y  exclude=statistics
###############gzip####################
gzip $DMP_DEST/*.dmp
##########################################deleted#######################################
echo "Cleaning up 1 week old backupfiles/logfiles ..." 
find $DMP_DEST -name '*.log' -mtime +$DMP_RETENTION -exec ls -l {} \;
find $DMP_DEST -name '*.log' -mtime +$DMP_RETENTION -exec rm -r {} \;
find $DMP_DEST -name '*.gz' -mtime +$DMP_RETENTION -exec ls -l {} \;
find $DMP_DEST -name '*.gz' -mtime +$DMP_RETENTION -exec rm -r {} \;
echo "cleaning completed.."


Still, it is not executing through crontab. Kindly suggest...

Regards,
Ashish Kumar Mahanta
Re: Unable to initiate crontab Job [message #623511 is a reply to message #623508] Thu, 11 September 2014 01:31 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

What does mean "it is not executing"?

Re: Unable to initiate crontab Job [message #623512 is a reply to message #623511] Thu, 11 September 2014 01:37 Go to previous messageGo to next message
ashishkumarmahanta80
Messages: 231
Registered: October 2006
Location: kolkatta
Senior Member
I mean...scheduled job is not running through crontab.
Re: Unable to initiate crontab Job [message #623513 is a reply to message #623512] Thu, 11 September 2014 01:51 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

What does mean "is not running"?

Re: Unable to initiate crontab Job [message #623517 is a reply to message #623512] Thu, 11 September 2014 03:01 Go to previous messageGo to next message
gazzag
Messages: 1118
Registered: November 2010
Location: Bedwas, UK
Senior Member
Check the following files for entries at the time that the script should have run:
/var/log/cron        # This is the log file that the cron daemon writes to. Check to see if your script even runs
/var/mail/oracle     # Anything written to stdout or stderr will be logged here. Post the output generated from your script if it did indeed run

While we're at it, what does the following produce?
ps -eaf|grep crond


HTH
-g
Re: Unable to initiate crontab Job [message #623524 is a reply to message #623517] Thu, 11 September 2014 04:04 Go to previous messageGo to next message
ashishkumarmahanta80
Messages: 231
Registered: October 2006
Location: kolkatta
Senior Member
Dear gazzag,

Please find the below output -
$ su - root
root's Password:
# ps -ef |grep crond
    root 1114258 1130626   0 20:53:37  pts/4  0:00 grep crond
# cat /var/log/cron
cat: 0652-050 Cannot open /var/log/cron.
# cd /var/log
# ls
csm          dirinst.log  pconsole
# cat /var/mail/oracle
cat: 0652-050 Cannot open /var/mail/oracle.
# cd /var/mail/
ksh: /var/mail/:  not found.
# id
uid=0(root) gid=0(system) groups=2(bin),3(sys),7(security),8(cron),10(audit),11(lp)


Please suggest, what could be else the reason?
Thanks for your positive response...
Re: Unable to initiate crontab Job [message #623525 is a reply to message #623524] Thu, 11 September 2014 04:09 Go to previous messageGo to next message
gazzag
Messages: 1118
Registered: November 2010
Location: Bedwas, UK
Senior Member
Apologies, I now see you are running AIX. I was using a Linux system. Anyway, no matter: the problem is that your cron daemon (crond) appears not to be running. Ask your Systems Administrator to start it.

HTH
-g
Re: Unable to initiate crontab Job [message #623532 is a reply to message #623525] Thu, 11 September 2014 04:42 Go to previous messageGo to next message
ashishkumarmahanta80
Messages: 231
Registered: October 2006
Location: kolkatta
Senior Member
Dear gazzag

Please let me know how to start the cron demeon...

Since, one job was already scheduled, which is working from the long. My scheduled job is having problem.

# cat cron.allow
oracle
root
# pwd
/var/adm/cron
# ls -ltr
total 121616
-rw-r--r--    1 root     sys            1313 Mar 31 2010  queuedefs
-rw-r-----    1 bin      cron              4 Mar 31 2010  at.deny
prw-------    1 root     cron              0 Sep 11 17:41 FIFO
-rw-rw-r--    1 bin      bin        62103788 Sep 11 21:25 log
-rw-r-----    1 bin      cron              2 Sep 11 21:26 cron.deny
-rw-r--r--    1 root     system            7 Sep 11 21:26 1
-rw-r--r--    1 root     system           12 Sep 11 21:29 cron.allow
# su - oracle
[YOU HAVE NEW MAIL]
executing this profile stage 0
$ crontab -l
00 05 * * * /oracledb1/backup/DB_EXP_BKUP/FIJIPROD/backup_database.sh
#34 17 * * * /oracledb1/DP_DIR_FIJIPROD/backup_database_expdp.sh


That job scripts are as below -

[code]
ORACLE_BASE=/oracledb/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/OraHome_1; export ORACLE_HOME
LIB_PATH=$ORACLE_HOME/lib; export LIB_PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
export LD_LIBRARY_PATH
PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin:$ORACLE_HOME/bin
export PATH
export EXPBACKUPDIR=/oracledb1/backup/DB_EXP_BKUP
export DAILY_EXP_LOG=$EXPBACKUPDIR/FIJIJIPRODUCTION_EXPORT_BKP.log
export EXPORT_PIPE=/tmp/BACKUP_pipe
touch $DAILY_EXP_LOG

function DBInstanceStatus {
HELP=0; VERBOSE=1
while getopts hv KEY $*
do
case $KEY in
v) VERBOSE=1;;
*) HELP=1;;
esac
done

FAILED=0; INSTANCEDOWN=0
for INSTANCE in $1
do
if [ ${VERBOSE} -eq "1" ] ; then
printf "Checking instance ${INSTANCE}...\n"
fi
for PROCESS in pmon smon
do
RC=$(ps -ef | egrep ${INSTANCE} | egrep -v 'grep' | egrep ${PROCESS})
if [ "${RC}" = "" ] ; then
INSTANCEDOWN=1
if [ ${VERBOSE} -eq "1" ] ; then
echo "ERROR: Instance: ${INSTANCE}--> ${PROCESS} Is Down !!" >> $DAILY_EXP_LOG
fi
fi
done
if [ ${INSTANCEDOWN} = "1" ] ; then
echo "`date` - Instance ${INSTANCE} is DOWN!!!\n" >> $DAILY_EXP_LOG
FAILED=1
else
echo "`date` - Instance ${INSTANCE} is running.\n" >> $DAILY_EXP_LOG
fi
done

if [ ${FAILED} = "1" ] ; then
export PROCEED=N
else
export PROCEED=Y
fi
}
function export_full_backup
{
ORACLE_SID=FIJIPROD; export ORACLE_SID
echo "checking Status of $ORACLE_SID Database" >> $DAILY_EXP_LOG
#Deletion OF PIPES AND VALIDATION
if [ -p $EXPORT_PIPE ]; then
rm $EXPORT_PIPE
fi
Dump_File=Full_Exp_`date +%d%m%y_%H_%M`_$ORACLE_SID.dmp.gz; export Dump_File
Log_File=Full_Exp_`date +%d%m%y_%H_%M`_$ORACLE_SID.log; export Log_File
EXPORT_COMP_DUMP=$EXPBACKUPDIR/$ORACLE_SID/$Dump_File; export EXPORT_COMP_DUMP
DBInstanceStatus $ORACLE_SID
if [ $PROCEED = "Y" ];then
echo "Taking Export Backup of $ORACLE_SID Database:Backup Dir=$EXPBACKUPDIR/$ORACLE_SID/:Log Dir:$EXPBACKUPDIR/$ORACLE_SID: Dump File Name=$Dump_File : Log File Name=$Lo
g_File" >> $DAILY_EXP_LOG

mknod $EXPORT_PIPE p
gzip < $EXPORT_PIPE > $EXPORT_COMP_DUMP &
exp system/oracle file=$EXPORT_PIPE log=$EXPBACKUPDIR/$ORACLE_SID/$Log_File consistent=y full=y direct=y statistics=none;

else
echo "`date` - $ORACLE_SID Database is Down..Skeeping Export Backup" >> $DAILY_EXP_LOG
fi

}
function purge_old_dump
{
ORACLE_SID=$1; export ORACLE_SID
echo "Proceeding To Purge Old Dumps Of $ORACLE_SID Database">> $DAILY_EXP_LOG
cd $EXPBACKUPDIR/$ORACLE_SID/
ToTDump=$(ls -ltr *.gz|wc -l)
ToTLog=$(ls -ltr *.log|wc -l)
echo "Total Number Of Dump Files In $EXPBACKUPDIR/$ORACLE_SID/ Directory Is $ToTDump " >> $DAILY_EXP_LOG
echo "Total Number Of Log Files In $EXPBACKUPDIR/$ORACLE_SID/ Directory Is $ToTLog " >> $DAILY_EXP_LOG
ToTDumpToPurg=`expr $ToTDump - 2`
ToTLogToPurg=`expr $ToTLog - 2`
if [ $ToTLogToPurg > 0 ];then
echo "------------------------------------" >> $DAILY_EXP_LOG
echo "Dump Files To Be Purged Are Fallowing " >> $DAILY_EXP_LOG
echo "------------------------------------" >> $DAILY_EXP_LOG
ls -lrt *.log|head -$ToTLogToPurg|awk -F" " '{print $9}'>> $DAILY_EXP_LOG
echo "------------------------------------" >> $DAILY_EXP_LOG
filelist=$(ls -lrt *.log|head -$ToTLogToPurg|awk -F" " '{print $9}')
for name in ${filelist[@]}
do
echo "Deleting File ---->"$name"...............">> $DAILY_EXP_LOG
rm $name
if [ -e $name ];then
echo "Deletion of $name is Failed " >> $DAILY_EXP_LOG
else
echo "Deletion of $name is Successfull" >> $DAILY_EXP_LOG
fi

done
fi


if [ $ToTDumpToPurg > 0 ];then
echo "------------------------------------" >> $DAILY_EXP_LOG
echo "Dump Files To Be Purged Are Fallowing " >> $DAILY_EXP_LOG
echo "------------------------------------" >> $DAILY_EXP_LOG

ls -lrt *.gz|head -$ToTDumpToPurg|awk -F" " '{print $9}'>> $DAILY_EXP_LOG
echo "------------------------------------" >> $DAILY_EXP_LOG
filelist=$(ls -lrt *.gz|head -$ToTDumpToPurg|awk -F" " '{print $9}')
for name in ${filelist[@]}
do
echo "Deleting File ---->"$name"...............">> $DAILY_EXP_LOG
rm $name
if [ -e $name ];then
echo "Deletion of $name is Failed " >> $DAILY_EXP_LOG
else
echo "Deletion of $name is Successfull" >> $DAILY_EXP_LOG
fi
done
fi

}



echo "##########################`date`#####################################" >> $DAILY_EXP_LOG
export_full_backup FIJIPROD
purge_old_dump FIJIPROD
echo "`date` Export Backup Compleated Successfully" >> $DAILY_EXP_LOG

echo "##########################End#####################################" >> $DAILY_EXP_LOG
[code]

If one job is running from long, my job should also run from crontab. But, it is not happening. Please guide me solve this issue...

Regards,
Ashish
Re: Unable to initiate crontab Job [message #623534 is a reply to message #623532] Thu, 11 September 2014 04:52 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

# su - oracle
[YOU HAVE NEW MAIL]


cron returns its output in mail, so read the mails and you may know the reason of "it is not executing" which we still don't know what it means.

Re: Unable to initiate crontab Job [message #623537 is a reply to message #623534] Thu, 11 September 2014 05:24 Go to previous messageGo to next message
gazzag
Messages: 1118
Registered: November 2010
Location: Bedwas, UK
Senior Member
As I said, I have no experience of AIX. Is there a file /etc/inittab ?
Re: Unable to initiate crontab Job [message #623635 is a reply to message #623537] Fri, 12 September 2014 04:42 Go to previous messageGo to next message
ashishkumarmahanta80
Messages: 231
Registered: October 2006
Location: kolkatta
Senior Member
Dear Michel,

Message shows of last dated notification.
Please check and let me know whether it is related to our activities?

Date: Sun, 7 Sep 2014 03:01:00 +1200
From: esaadmin
Message-Id: <201409061501.s86F10mw1421528@fijiprod>
To: root
Subject: Electronic Service Agent not activated

Electronic Service Agent has not been activated.  To activate Electronic Service Agent, do the following:  From the SMIT main menu, select Electronic Service Agent, then select Con
figure Electronic Service Agent.

For information about Electronic Service Agent, including the benefits of activating it, see the following:
http://publib.boulder.ibm.com/infocenter/eserver/v1r2/topic/eicbd/eicbdkickoff.htm

#


Regards,
Ashish
Re: Unable to initiate crontab Job [message #623636 is a reply to message #623635] Fri, 12 September 2014 04:48 Go to previous messageGo to next message
gazzag
Messages: 1118
Registered: November 2010
Location: Bedwas, UK
Senior Member
Have you tried posting your question in an AIX forum? The tumbleweed blowing through this thread would imply that we have little AIX skills around here Smile
Re: Unable to initiate crontab Job [message #623683 is a reply to message #623635] Fri, 12 September 2014 10:18 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

This has nothing to do with your cron job.
These are messages from root mailbox and you run the script from oracle crontab.

[Updated on: Fri, 12 September 2014 10:18]

Report message to a moderator

Previous Topic: automating a script
Next Topic: SP2-0670: Internal number conversion failed even if I return a number
Goto Forum:
  


Current Time: Fri Mar 29 02:06:33 CDT 2024