1758338 Members
2667 Online
108868 Solutions
New Discussion юеВ

time difference

 
SOLVED
Go to solution
akarayil
Frequent Advisor

time difference

Hi friends,

I've scheduled to export oracle DB everyday at 7AM, by executing the script given below:

#!/usr/local/bin/bash

exportORACLE_HOME=/a1/app/oracle/product/10.1.0
flnm=bkp`date +%a_%H%M`.dat
echo "Exporting Backup to : $flnm on `date +%d/%m/%Y-%H:%M:%S`" >> /home/ora/backup.log
if [ $UID == 255 ]; then
$ORACLE_HOME/bin/exp system/mastermind@ems file=(/a2/ora/1_$flnm,/a2/ora/2_$flnm,/a2/ora/3_$flnm) filesize=4G owner=(nabad,abc_dev) triggers=y compress=y rows=y statistics=none log=/home/ora/logbkp.log1

else
echo "You must logged in as ORACLE user"
fi
echo "====== Backup Completed on `date +%d/%m/%Y-%H:%M:%S` =====" >> /home/ora/backup.log
echo "====== Backup transfer start `date +%d/%m/%Y-%H:%M:%S` =====" >> /home/ora/backup.log

Its running fine.

As I'm running this script at 7AM, the file names generated should be bkpMon_0700.dat but I'm getting a file name of bkpSun_2130.dat

In /var/adm/cron/log, it shows that the script runs at 7Am.
Can anybody help me out?
12 REPLIES 12
Aashique
Honored Contributor

Re: time difference

Hi,
There is nothing wrong in the script.The date format also ok.
Please check your system date.

Thanks & Regards

Aashique
Jeeshan
Honored Contributor

Re: time difference

Hi

The time you get is, when the backup has last finished.
a warrior never quits
Dennis Handly
Acclaimed Contributor

Re: time difference

What's your timezone? TZ=IST=-5:30 ?
If so, that maybe the difference between 7 AM and 9:30 PM, EDT.
So, you need to export TZ to your correct timezone.
akarayil
Frequent Advisor

Re: time difference

Dear ashique,

system date&time is running fine. In the cron log file, exact time is showing. It starts at 7AM & takes 30 to 45 minutes to complete the process.

my time zone is IST-5:30
Dennis Handly
Acclaimed Contributor

Re: time difference

>my time zone is IST-5:30

Then you'll have to export it in your cronjob:
export TZ=IST-5:30
Yogeeraj_1
Honored Contributor

Re: time difference

> Ahsan
> The time you get is, when the backup has last finished.

this is not true. The name of the file is generated prior to the execution of the EXP command. So it should be close to the time the script is scheduled for execution.

See above:
flnm=bkp`date +%a_%H%M`.dat


It is definitely related to the timezone settings of the user who has the script scheduled in its crontab.

Please verify as per Dennis post above.

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Dennis Handly
Acclaimed Contributor

Re: time difference

>ME: Then you'll have to export it in your cronjob:

Or you can put it in your crontab entry:
00 07 * * * TZ=IST-5:30 backup_script ...
Jeeshan
Honored Contributor

Re: time difference

Hi again

check your users time zone. e.g. root, oracle

from root user
#echo $TZ

from oracle user
#echo $TZ

I guess that earlier in my prfevious post.
If i'm not wrong, from the user you run this script is only using that users date.

BTW, what is findings?
a warrior never quits
Aashique
Honored Contributor

Re: time difference

Hi,
try with this:
top of the script put your TZ value and then export TZ it.


Thanks & Regards