LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   schedule job to be run at 8:00pm every night (https://www.linuxquestions.org/questions/linux-general-1/schedule-job-to-be-run-at-8-00pm-every-night-107576/)

ashley75 10-07-2003 03:57 PM

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

ehdwuld 10-07-2003 04:30 PM

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

at the very bottom of the page

cron is what you want

Blinker_Fluid 10-07-2003 04:40 PM

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

ashley75 10-08-2003 09:19 AM

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

Blinker_Fluid 10-08-2003 09:50 AM

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

ashley75 10-08-2003 10:22 AM

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

Blinker_Fluid 10-08-2003 10:39 AM

looks like it does not have execute permissions to me...
chmod 744 /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh

ashley75 10-08-2003 11:15 AM

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.

Blinker_Fluid 10-08-2003 11:45 AM

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?

ashley75 10-08-2003 01:28 PM

sorry it's typo:

the right one on crontab is:


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

any suggestion????


Blinker_Fluid 10-08-2003 02:42 PM

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)

ashley75 10-08-2003 02:57 PM

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

Blinker_Fluid 10-08-2003 04:25 PM

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

ashley75 10-23-2003 09:55 AM

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

tyccea 10-23-2003 10:02 AM

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.


All times are GMT -5. The time now is 08:33 PM.