LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-07-2003, 04:57 PM   #1
ashley75
Member
 
Registered: Aug 2003
Posts: 231

Rep: Reputation: 30
schedule a job to be run at 8:00pm every night


Hi all,

If I have a job .sh and this file need to be run every night at 8:00pm, can somone please tell me how to do this???

thanks
 
Old 10-07-2003, 05:30 PM   #2
ehdwuld
Member
 
Registered: Jul 2003
Distribution: Currently Suse 11.1 but have RH7,8,9 / Fedora 7,8_64,9_64,&10_64
Posts: 634

Rep: Reputation: 30
http://www.tldp.org/LDP/intro-linux/...ect_04_04.html

at the very bottom of the page

cron is what you want
 
Old 10-07-2003, 05:40 PM   #3
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 682

Rep: Reputation: 63
crontab -e
Put a line in something similar to this: (fill in full path to the script)
0 20 * * * /home/user/script_to_be_run.sh

what it means...
Minute Hour Day month day_of_week script_to_run
 
Old 10-08-2003, 10:19 AM   #4
ashley75
Member
 
Registered: Aug 2003
Posts: 231

Original Poster
Rep: Reputation: 30
Binker_fluid,

thanks for your help. quick question:

1. Do I have to log in as root???

2. all I have to do is type: crontab -e and add the time I want the job to be run???

that's it!!!!
 
Old 10-08-2003, 10:50 AM   #5
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 682

Rep: Reputation: 63
You can run a cron job as a normal user. You don't have to be root.
to set up cron you type crontab -e and it will probably just look like a file you opened in vi. You then can add the line and :wq! to save it. If you want to view what is in the cron file you can type crontab -l
good luck
 
Old 10-08-2003, 11:22 AM   #6
ashley75
Member
 
Registered: Aug 2003
Posts: 231

Original Poster
Rep: Reputation: 30
thanks for your help, I did schedule the job and I got the below error on oracle mail:


From oracle Wed Oct 8 09:10:00 2003
Return-Path: <oracle@localhost.localdomain>
Received: (from oracle@localhost)
by localhost.localdomain (8.11.6/8.11.6) id h98FA0T06982
for oracle; Wed, 8 Oct 2003 09:10:00 -0600
Date: Wed, 8 Oct 2003 09:10:00 -0600
Message-Id: <200310081510.h98FA0T06982@localhost.localdomain>
From: root@localhost.localdomain (Cron Daemon)
To: oracle@localhost.localdomain
Subject: Cron <oracle@db01> /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/oracle>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracle>

/bin/sh: /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh: Permission denied


but when I look into permission, oracle owned the scripts:

-rw-r--r-- 1 oracle oinstall 210 Oct 7 14:43 backup_TEST.sh


Any suggestions of what happened????

thanks

Last edited by ashley75; 10-08-2003 at 11:30 AM.
 
Old 10-08-2003, 11:39 AM   #7
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 682

Rep: Reputation: 63
looks like it does not have execute permissions to me...
chmod 744 /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh
 
Old 10-08-2003, 12:15 PM   #8
ashley75
Member
 
Registered: Aug 2003
Posts: 231

Original Poster
Rep: Reputation: 30
SORRY, I ran into different problem now:

for oracle; Wed, 8 Oct 2003 10:10:00 -0600
Date: Wed, 8 Oct 2003 10:10:00 -0600
Message-Id: <200310081610.h98GA0h07601@localhost.localdomain>
From: root@localhost.localdomain (Cron Daemon)
To: oracle@localhost.localdomain
Subject: Cron <oracle@qhoudb03> /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/oracle>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracle>

/home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh: Echo: command not found
/home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh: ^M: command not found
/home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh: ^M: command not found
/home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh: ^M: command not found
/home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh: exp: command not found


below is what I have on crontab:

10 10 * * * /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh






and in my scripts (backup_TEST.sh) is very simple, basically, it export the database and it run fine manually.

Last edited by ashley75; 10-24-2003 at 01:21 PM.
 
Old 10-08-2003, 12:45 PM   #9
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 682

Rep: Reputation: 63
Does /home/oracle/DBA_STUFFS/backup_scripts/HULAND01/backup_HULAND01.sh
call the /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh script? If it does does that script have execute permissions? Have you made a typo so it's something like Test instead of TEST?
 
Old 10-08-2003, 02:28 PM   #10
ashley75
Member
 
Registered: Aug 2003
Posts: 231

Original Poster
Rep: Reputation: 30
sorry it's typo:

the right one on crontab is:


10 10 * * * /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST01.sh

any suggestion????


Last edited by ashley75; 10-08-2003 at 02:30 PM.
 
Old 10-08-2003, 03:42 PM   #11
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 682

Rep: Reputation: 63
So when you run it with the typo fixed do you get an error?
I would do a crontab -l
then take whatever the command is and do a ls -l on it to make sure it has the correct permissions and exists...
Try running it from command line and see if you get an error (don't do ./backup_TEST01.sh Do the entire path that you have in crontab /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST01.sh)
 
Old 10-08-2003, 03:57 PM   #12
ashley75
Member
 
Registered: Aug 2003
Posts: 231

Original Poster
Rep: Reputation: 30
something weird with my script:

I have permission to execute the

scripts: ./home/oracle/scripts/backup/TEST/backup_TEST.sh
bash: ./home/oracle/scripts/backup/TEST/backup_TEST.sh: No such file or directory


I am sure the file is there.

when I go to ./home/oracle/scripts/backup/TEST/ and the file is there so I tried: ./backup_TEST.sh and I got the error:

[oracle@qhoudb03 HULAND01]$ ./backup_TEST.sh
./backup_TEST.sh: Echo: command not found
: command not foundh:
: command not foundh:
: command not foundh:

Export: Release 9.2.0.4.0 - Production on Wed Oct 8 14:52:00 2003

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


EXP-00056: ORACLE error 1034 encountered
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
EXP-00005: all allowable logon attempts failed
EXP-00000: Export terminated unsuccessfully


The database is up and running at all time


BELOW ARE THE COMMAND ON MY backup_TEST.sh:

export ORACLE_SID=TEST

exp system/manager file=...............


Sorry for this problem since I am new and trying to learn
 
Old 10-08-2003, 05:25 PM   #13
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 682

Rep: Reputation: 63
You may want to make sure that all the things are defined that need to be for the script. Sometimes I have seen Database scripts not work because commands are actually aliased to some other much longer command that people take for granted.
example:
user might type something like 'which x' and the output is something like
# which x
alias x='clear'
/usr/bin/clear

however the user may not realize that there is actually an alias set up --> alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

so when they run it in a script and the alias is not set up they get something like this:
#which x
which: no x in (/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/foo/bin)

Now you can add the alias to the script and have it work but it will not by default (scripts don't read your .profile, .bashrc, etc)
Hope that helps
 
Old 10-23-2003, 10:55 AM   #14
ashley75
Member
 
Registered: Aug 2003
Posts: 231

Original Poster
Rep: Reputation: 30
schedule job to be run at 8:00pm every night

SORRY THIS QUESTION may be too easy for some experts in here but I am new so please help:

I like to schedule a job to be run at 8:00pm every night, and I know very a little about cron
job, basically I just want to get the exp of the database every night. Please correct me if I
am wrong. I have the script as below:

export ORACLE_SID=TEST

exp DBBCKUP/D88CKUP file=/u02/backup/TEST/exp_TEST_full.dmp
log=/u02/backup/TEST/exp_TEST_full.log full=y direct=y

and this script is save as backup_TEST.sh and it located on:
/home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh
 
Old 10-23-2003, 11:02 AM   #15
tyccea
Member
 
Registered: Aug 2003
Location: atlanta, ga
Distribution: SuSE 8.2
Posts: 90

Rep: Reputation: 15
http://freebooks.by.ru/view/LinuxNet...htm#Heading372

snippet: "First, let's see how you can automate the execution of scheduled tasks."
It's a decent article.

Last edited by tyccea; 10-23-2003 at 11:04 AM.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Schedule a Script to Run nutthick Linux - Newbie 8 02-02-2005 01:37 PM
how to schedule an "at" job to start when another finishes? ashlock Programming 10 01-14-2005 12:12 AM
How to schedule an automated job macaldwell Linux - Newbie 8 05-29-2004 03:07 PM
schedule 'e2fsck' to run on startup, possible? BxBoy Linux - General 1 02-18-2004 01:15 PM
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 02:06 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration