LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-19-2007, 10:40 PM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 504

Rep: Reputation: 31
scripts run on 9:30 AM daily


Dear Friends ,

I have to run a script daily at 9:30 am . my script locates in suppose in /test directory .

How can I do it ?
 
Old 08-19-2007, 10:50 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
You would do this with cron. As the user you want the script to run as, give the command "crontab -e" and then enter in the following information:

Code:
# Run script at 9:30 daily:
30 9 * * * /path/to/script
 
Old 08-20-2007, 08:14 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Just to expand on the answer, note that the cron env is minimal, which means that if you call any programs, inc Linux ones, always specify the full paths to those as well.
If cron has a problem, it should email either the user or root.
 
Old 08-23-2007, 11:38 PM   #4
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 504

Original Poster
Rep: Reputation: 31
can't run script auto using crontab ?

Dear ,

Thx for ur reply .

Actually I have to run the follwoing Export Database Script as OAcle user at every 9:30 A.M.
The script is :

"#!/bin/bash
# Script for interactive import
# Inputs are database name, list of owners


Date1=`date +%d%b%Y`
Date=`date +%d%b%Y`.`date +%I`.`date +%M%p`
mkdir -p /backup/DBbackup/bscdb/$Date1


printf " Enter the Database name [ORACLE SID] which has to be exported : "
read OraSid
export ORACLE_SID=$OraSid
exp / file=/backup/DBbackup/bscdb/$Date1/$OraSid.$Date.dmp full=y statistics=none direct=y log=/backup/DBbackup/bscdb/$Date1/$OraSid.$Date.exp.log "

I have to add the above script into the "CRONTAB" Like following way :


crontab -e //as ORACLE user's crontab
# Run script at 9:30 daily:
30 9 * * * /path/to/script //according to ur mail

But the problem is , I dont get any output . Just create the Dated folder only , no dump file is created . All of folder permission are correct but script is not working using the CRONTAB . Here I mention that manually the script is working but I want to run this script using crontab .

Plz give me suggestion How can I run the following script using CRONTAB ?
 
Old 08-23-2007, 11:54 PM   #5
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 504

Original Poster
Rep: Reputation: 31
can't run script auto using crontab ?

Dear ,

Thx for ur reply .

Actually I have to run the follwoing Export Database Script as OAcle user at every 9:30 A.M.
The script is :

"#!/bin/bash
# Script for interactive import
# Inputs are database name, list of owners


Date1=`date +%d%b%Y`
Date=`date +%d%b%Y`.`date +%I`.`date +%M%p`
mkdir -p /backup/DBbackup/bscdb/$Date1


printf " Enter the Database name [ORACLE SID] which has to be exported : "
read OraSid
export ORACLE_SID=$OraSid
exp / file=/backup/DBbackup/bscdb/$Date1/$OraSid.$Date.dmp full=y statistics=none direct=y log=/backup/DBbackup/bscdb/$Date1/$OraSid.$Date.exp.log "

I have to add the above script into the "CRONTAB" Like following way :


crontab -e //as ORACLE user's crontab
# Run script at 9:30 daily:
30 9 * * * /path/to/script //according to ur mail

But the problem is , I dont get any output . Just create the Dated folder only , no dump file is created . All of folder permission are correct but script is not working using the CRONTAB . Here I mention that manually the script is working but I want to run this script using crontab .

Plz give me suggestion How can I run the following script using CRONTAB ?
 
Old 08-24-2007, 06:19 AM   #6
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Well your script looks like it depends on user input to actually do anything (the name of the Oracle DB), so it won't work when run autonomously like that.

You would need to hard-code the name of the database into the script, because nobody is going to be able to actually interact with the script when it is running.
 
Old 08-24-2007, 11:48 AM   #7
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 504

Original Poster
Rep: Reputation: 31
script using crontab : not work

Thx MS3FGX ,

Ok I have to change my script so that user need not to give Database name manually .

"#!/bin/bash
# Script for interactive import
# Inputs are database name, list of owners


Date1=`date +%d%b%Y`
Date=`date +%d%b%Y`.`date +%I`.`date +%M%p`
mkdir -p /backup/DBbackup/bscdb/$Date1


export ORACLE_SID=orcl
exp / file=/backup/DBbackup/bscdb/$Date1/orcl.$Date.dmp full=y statistics=none direct=y log=/backup/DBbackup/bscdb/$Date1/orcl.$Date.exp.log "

But still problem is not solved . plz give me some advice ... waiting for ur reply ...
 
Old 08-27-2007, 01:37 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Exactly what problem have you now got?
Have you set it up as a cron job as described above?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need tips on creating scripts for daily backup (tar) a directory to an external drive Joejr4u Linux - Server 2 06-07-2007 07:46 AM
change cron.daily run time jimmyjiang Red Hat 4 03-02-2007 01:35 PM
How to run jobs in /etc/cron.daily? Micro420 Linux - Newbie 4 10-19-2006 02:07 PM
Mail daily logs through shell scripts klnasveschuk Linux - Software 0 08-07-2003 05:02 AM
how do i schedule events to run daily. ThaddNZ2003 Linux - General 2 03-10-2003 10:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration