LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   scripts run on 9:30 AM daily (https://www.linuxquestions.org/questions/linux-newbie-8/scripts-run-on-9-30-am-daily-578303/)

shipon_97 08-19-2007 10:40 PM

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 ?

MS3FGX 08-19-2007 10:50 PM

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


chrism01 08-20-2007 08:14 PM

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.

shipon_97 08-23-2007 11:38 PM

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 ?

shipon_97 08-23-2007 11:54 PM

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 ?

MS3FGX 08-24-2007 06:19 AM

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.

shipon_97 08-24-2007 11:48 AM

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 ...

chrism01 08-27-2007 01:37 AM

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


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