Crontab Scheduling

Sun / Sun-fire-v490
Amit Kumar January 27, 2009 at 02:05:54
Specs: Solaris 5.10, Sparc
Hi I am new to Solaris environemnt I have created a script that takes the backup of oracle database the script is as follow:
===========================================
#!/bin/sh
#Backup script by Amit Kumar 23-Jan-2009.


#PATH=/usr/sbin:/opt/oracle/product/10.2.0/bin:/usr/bin:/usr/local/bin
#ORACLE_HOME=/opt/oracle/product/10.2.0
#export PATH ORACLE_HOME


expdate=`date '+%d%m%Y'`
dat=`date '+%m%d%y %H:%M:%S'`
echo "Backup started..." $dat;

expdp system/Systempfyi08! FULL=y DIRECTORY=ps DUMPFILE=expdp$expdate.dmp LOGFILE=expdp$expdate.log

echo "Backup Completed." $dat;

gzip /opt/oracle/export/no2p4/ps/expdp$expdate.dmp
===========================================


And I have tested this script by runing manualy. It is working fine.

But I am facing the problem while I am planning to add this script to cratab file for automating the process.

The crontab file entries are:

===========================================
30 22 * * * sh /opt/oracle/amit_export.sh >> /opt/oracle/amit_export.log
===========================================

But as per entry the script does not execute automatically as per time settings.

Please suggest me what to do.....


See More: Crontab Scheduling

Report •


#1
January 27, 2009 at 09:40:39
I have 3 observations:

1) When a script fails from cron, but works from the command line, the most common problem is that the shell variables, such as PATH, aren't set. Cron's PATH will not be the same as a typical user's PATH.

You have commented yours out. Why?

Cron's default shell is tyically #!/bin/sh. It's always a good idea to set the proper shell (which you've done).

2) After reviewing your script, it looks like it won't work unless your parent directory contains a directory called expdp. Got that from this:

expdp$expdate.dmp

When cron runs the script, it will probably look in the root directory for directory expdp. Either use full paths for your files or cd to the parent directory where expdp resides before executing the backup.

3) There is no reason to execute the cron command with sh. Change this:

30 22 * * * sh /opt/oracle/amit_export.sh >> /opt/oracle/amit_export.log

to:

30 22 * * * /opt/oracle/amit_export.sh >> /opt/oracle/amit_export.log


Report •

#2
January 27, 2009 at 15:21:40
I agree with cron issue.

"Best Practices", Event viewer, host file, perfmon, antivirus, anti-spyware, Live CD's, backups, are in my top 10


Report •

#3
April 10, 2009 at 04:16:46
Hi all,

Anyone to help me to run my scripts using ksh in Solaris 5.10.

I have tried a simple script using sh but still not working. I already checked cron.allow, and my user is defined. cron.deny also exist in /etc/cron.d but of course my user in not in that file.

Any suggestions.


Your help will be very much appreciated.

hueman


Report •


#4
July 1, 2010 at 04:02:22
Hi,
Pls run the script manually,from the command line.

Report •

#5
July 16, 2011 at 07:49:45
Hi all,

Anyone to help me how to create the scripts below mentions file names using sh in Solaris 10
my scripts file name is :Checkdisha.log
backup file name is : Checkdisha.logfile

i want to run the scripts every 2 hours

please create scripts


Report •


Ask Question