Crontab - entry not working , cron job not running

I have put a cron entry in oracle user for taking hot backup every wednesday@ 2.30 AM and have given the cron entry

30 02 * * 3 /u01/vijay/hotbackupcron 2>&1 >> /u01/vijay/hotbackup.log

also find below the script inside hotbackupcron, i have put in env variables as well

#!/bin/bash
ORACLE_BASE=/u02/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/test; export ORACLE_HOME
ORACLE_SID=test; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
 
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
cd /u01/vijay
sqlplus -s /nolog <<EOF
conn / as sysdba
@hotbackup
exit
EOF

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

This cron entry is not working at the specified time, please let me know what is the mistake I am doing

Does it work at all? When does it run?

Did you have a look at the cron logs? Who is executing this crontab? No mail?
I see a few things but interested in knowing what cron says first...

And is cron services activated?...

It doesnot run at the time and it never runs as i see the log file is not even being created

---------- Post updated at 05:13 AM ---------- Previous update was at 05:12 AM ----------

Yes no mail. the user is oracle. the log file is not being created.

can you help me fixing this.

Does user oracle have the permissions to write that log file? Do you receive oracle's mails? Can you check the system logs and post the result?

Yes oracle user has the permission to write in that log.

but no log file is even created which means it didn't run at all.

how to check system log+ also we dont receive mails

Does ps show a *cron process? If not, start the service.
Run

grep cron /var/log/messages

and post a few last lines of the result.
Put

MAILTO=< your account>
*/5 * * * * pwd

into the crontab (if that construct is allowed on your system), check your mails and report back.

1 Like

ps shows a cron process and it is owned by root user

i dont get any search results for grep cron /var/log/messages

I am newbie here to my company, so not sure i can configure mail

please advise

I'm out of ideas. Have your sys admins help you.

Well next thing is, is the user oracel allowed to use corn (sorry Im dislecsic today if you see funny things...) : Do you have /var/adm/cron/cron.* files (.deny or .allow ) if so what is in them...
try with this order:

30 02 * * 3 /u01/vijay/hotbackupcron >> /u01/vijay/hotbackup.log  2>&1 

oracle has permission to write in /u01/vijay ?

This should not be set:

ORACLE_TERM=xterm; export ORACLE_TERM

Using cron, you have no terminal and cron will complain if it sees anything terminal or keyboard stuff ( tty ...)

Check for other log files in /var/log as well (e.g. syslog & cron.log)

What's the permissions of your script, and the directory it's in?

ls -la /u01/vijay/hotbackupcron
ls -lad /u01/vijay
1 Like

Hope I found the answer . there are no exceute permissions on the cron scripts

i gave the execute permissions by chmod +x hotbackupcron

hope it should run tonight and i will post reply tomorrow morning

chmod +x hotbackupcron

To who? The owner? the group? other?...
In other words you haven't tested your script...
Before posting "I have issues with a script in cron" you should have tested : That means as oracle, does the script gets executed!
If not, solve the issue before thinking to execute it as a batch using cron...