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 |
http://www.tldp.org/LDP/intro-linux/...ect_04_04.html
at the very bottom of the page cron is what you want |
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 |
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!!!! |
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 |
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 |
looks like it does not have execute permissions to me...
chmod 744 /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh |
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. |
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? |
sorry it's typo:
the right one on crontab is: 10 10 * * * /home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST01.sh any suggestion???? |
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) |
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 |
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 |
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 |
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. |