03-11-2004
Backup with shell program and cron job.
Hi,
The object of my program is to take automatic backup on daily basis to different folders. I have created the respective folders. when I execute below given shell program manually it is working perfectly and taking the backup to respective folder.
#!/bin/sh
#script to take backup on day basis, This is going to run from cron job.
#
while :
do
clear
yourch=`date +%u`
case $yourch in
1) exp backuser/backuser@linux1 file=/disk4/backup/Mon/linux1_Mon.dmp log=/disk4
/backup/Mon/linux1_Mon.log full=y direct=Y compress=N rows=N; exit 0;;
2) exp backuser/backuser@linux1 file=/disk4/backup/Tue/linux1_Tue.dmp log=/disk4
/backup/Tue/linux1_Tue.log full=y direct=Y compress=N rows=N; exit 0;;
3) exp backuser/backuser@linux1 file=/disk4/backup/Wed/linux1_Wed.dmp log=/disk4
/backup/Wed/linux1_Wed.log full=y direct=Y compress=N;rows=Y exit 0;;
4) exp backuser/backuser@linux1 file=/disk4/backup/Thu/linux1_Thu.dmp log=/disk4
/backup/Thu/linux1_Thu.log full=y direct=Y compress=N rows=N; exit 0;;
5) exp backuser/backuser@linux1 file=/disk4/backup/Fri/linux1_Fri.dmp log=/disk4
/backup/Fri/linux1_Fri.log full=y direct=Y compress=N rows=N; exit 0;;
6) exp backuser/backuser@linux1 file=/disk4/backup/Sat/linux1_Sat.dmp log=/disk4
/backup/Sat/linux1_Sat.log full=y direct=Y compress=N rows=Y; exit 0;;
esac
done
When the same program kept in cron, it is not working.
IF I EXECUTE NORMAL COMMAND IN THE CRON WITH OUT SHELL THEY ARE WORKING WHEN I KEEP ANY SHELL PROGRAMS, THEY ARE NOT WORKING.
0 23 * * * /home/oracle/backup/backup.sh
> /home/oracle/backup/backup.log
The backup.log file is creating with 0 bytes.
Please help me in solving this problem.
With Regards
Varma.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Just I'm trying to find script, which will do the following job:
1. as a CRON-Job it shoult
a) delete files which will be either older than 24 hours or
b) all files within
a) a directory deleting recursive
b) only a special directory.
2. write an error-/Delete_log... (9 Replies)
Discussion started by: ManfredWL
9 Replies
2. UNIX for Dummies Questions & Answers
My shell script runs fine both as a cron job and when i issue it.
However, I wish to differentiate when it runs as a cron-job so the "echo" statements are not issued (they get mailed to me, which i don't want).
I tried checking $USER but since the cron was created in my user that does not... (5 Replies)
Discussion started by: sentinel
5 Replies
3. Shell Programming and Scripting
Hi I have a website that is having problem with cron jobs...
I have a cron job set up to go to a page with this code...
<?
include('config.php');
if($_sys->bible_email_frequency == 'DAILY')
{
$u = new user();
$u->send_bible_email();
}
?>
If i send my browser to this page... (2 Replies)
Discussion started by: whybelieve
2 Replies
4. Shell Programming and Scripting
Hey Guys,
i was trying out a shell script which has to remove a file for every 90 mins. this is the code i came up with .
$ crontab -e file1
file1 contains
30 1 * * * * rm -r /folder1/folder2/somefile.txt
Now i need the cron to run for every 90 mins. the problem with this is... (8 Replies)
Discussion started by: Irishboy24
8 Replies
5. Shell Programming and Scripting
i have just installed a cron job to run at 3 in the morning once a week. It's difficult for me to test if it works because the email backup program takes the email service down before running the backup. I wondered if i could ask you gurus if this would work?
0 3 * * 0 ... (1 Reply)
Discussion started by: timgolding
1 Replies
6. Solaris
Hi,
The following shell script runs without any problem when executed manulally.
USED=$(df -h /arch | tail -1 | awk '{print $5}' | cut -d '%' -f 1)
if
then
find /arch/AUBUAT/ -type f -mtime +0 | xargs rm
find /arch/AUBMIG/ -type f -mtime +0 | xargs rm
fi
But the same gives below... (6 Replies)
Discussion started by: ksadiq79
6 Replies
7. UNIX for Dummies Questions & Answers
Hi am newbie for unix shell..
how to create a cron job for my already created shell script.:confused:
Thanks! (1 Reply)
Discussion started by: vidhyaS
1 Replies
8. Shell Programming and Scripting
Dear experts,
I have this cronjob
* */2 * * * $path/supervisor.sh The supervisor script is checking another script, which initializes the final scripts in multiple directories.
Note that the supervisor script runs without the cronjob.
In each directory, I have the following script:
... (2 Replies)
Discussion started by: TheTransporter
2 Replies
9. Shell Programming and Scripting
how to write a code using shell scripting to refire a back up job if it fails with an error code of 196? (7 Replies)
Discussion started by: Pawan Ramnani
7 Replies
10. Shell Programming and Scripting
I am trying a cron on root user to backup to tape using TAR command
here is the cron entry
11 08 * * 6 /erdhot1cron 2>&1 >> /test3/scripts/dba/erdhot1cron.log
here is script inside - edhot1cron
#!/bin/bash
vsysdt=`date +%d%m%y`
date
tar -cvf /dev/st0... (4 Replies)
Discussion started by: vijaymec50
4 Replies
LEARN ABOUT CENTOS
db2bak
DB2BAK(8) System Manager's Manual DB2BAK(8)
NAME
db2bak - Directory Server script for making a backup of the database
SYNOPSIS
db2bak [archivedir] [-Z serverID] [-q] [-h]
DESCRIPTION
Creates a backup of the database. This script can be executed while the server is running or stopped.
OPTIONS
A summary of options is included below:
archivedir
The full path to the directory to store the backup.
-Z Server Identifier
The server ID of the Directory Server instance. If there is only one instance on the system, this option can be skipped.
-q
Quiet mode. Reduces output of task.
-h
Display the usage.
EXAMPLE
db2bak -Z instance2
Makes a backup of the entire database for 'instance2', and stores it in the default server instance backup directory.
db2bak /LDAP/backups/20130305
Creates a backup of the database and stores it in specified location.
DIAGNOSTICS
Exit status is zero if no errors occur. Errors result in a non-zero exit status and a diagnostic message being written to standard error.
AUTHOR
db2bak was written by the 389 Project.
REPORTING BUGS
Report bugs to http://bugzilla.redhat.com.
COPYRIGHT
Copyright (C) 2013 Red Hat, Inc.
Mar 5, 2013 DB2BAK(8)