LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 11:40 PM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 484

Rep: Reputation: 30
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, 11:50 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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, 09:14 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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-24-2007, 12:38 AM   #4
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 484

Original Poster
Rep: Reputation: 30
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, 12:54 AM   #5
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 484

Original Poster
Rep: Reputation: 30
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, 07:19 AM   #6
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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, 12:48 PM   #7
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 484

Original Poster
Rep: Reputation: 30
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, 02:37 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:46 AM
change cron.daily run time jimmyjiang Red Hat 4 03-02-2007 02:35 PM
How to run jobs in /etc/cron.daily? Micro420 Linux - Newbie 4 10-19-2006 03:07 PM
Mail daily logs through shell scripts klnasveschuk Linux - Software 0 08-07-2003 06:02 AM
how do i schedule events to run daily. ThaddNZ2003 Linux - General 2 03-10-2003 11:59 AM


All times are GMT -5. The time now is 12:47 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration