Problem with crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with crontab
# 8  
Old 07-15-2010
Let's get some base facts.

Which Operating System?
Which Shell?
Which database engine?
What is in the script?
What is in the crontab line?
Which user did you use test from the command line?
Which user owns the crontab?
Any error messages in unix mail for the user?
# 9  
Old 07-15-2010
I wud be posting all details, just let me know how to check who owns crontab?

---------- Post updated at 08:41 PM ---------- Previous update was at 07:41 PM ----------

Quote:
Originally Posted by methyl
Let's get some base facts.

Which Operating System?
Which Shell?
Which database engine?
What is in the script?
What is in the crontab line?
Which user did you use test from the command line?
Which user owns the crontab?
Any error messages in unix mail for the user?
1) Sun Solaris
2) Ksh shell
3) sqlplus (Oracle)
4) Code

Code:
#!/bin/ksh
LOG=/log/AT.log
MESSAGE=/log/MESSAGE_AT.txt
mail_list=/AT_MAIL_LIST.txt
data=/log/spooled_AT.log
SIGNATURE=/log/AT_Signature.txt
echo "`date` Starting execution for ATCOUNT" > $LOG
 
RESULT=`$ORACLE_HOME/bin/sqlplus -s schema/pwd@abc << EOF
        set echo off;
        set heading off;
        set feedback off;
        set trimspool on;
        @/log/AT.sql
`
echo $RESULT >> $LOG
 
echo " `date` End of step generation of AT COUNT has completed" >> $LOG
 
touch temp_file
touch temp1
echo "AT count is "> temp_file
cat $data >> temp_file
cat temp_file $SIGNATURE > temp1
mv temp1 $MESSAGE
rm temp_file
 
mailx -r"abc@aaa.com" -s " ATT PMT NIKU Count `date` "  `cat $mail_list`<$MESSAGE
echo "mail has been sent" >> $LOG

Code for sql file:

Code:
spool /log/spooled_AT.log
select count(*) from AT;
spool off;
exit;

5) Crontab Line
Code:
 
25 12 * * * /scripts/AT_COUNT.ksh

6 & 7 ) same user is used for both crontab and manual run
8) No error.



I am creating multiple files, all working fine, then y only spooled one is having error...... Pls Help.......!
# 10  
Old 07-15-2010
  1. don't assume crontab knows about $ORACLE_HOME
  2. temp_file and temp1 have no 'absolute' path definition
Once again - I'd strongly encourage looking into the FAQs.

Last edited by vgersh99; 07-15-2010 at 12:47 PM..
# 11  
Old 07-15-2010
Nice to see the shebang line at the top of the script.

Agreed. As a minimum for the Oracle environment we'll need:
Code:
ORACLE_HOME="/wherever_oracle_home_is"   ;  export ORACLE_HOME
ORACLE_SID="sidname"  ; export ORACLE_SID
PATH="${PATH}:${ORACLE_HOME}/bin"  ; export PATH

There still may be a question about which user? When issuing the "crontab" command the default user is "root" unless you specify a different user. If we assume that this is a root cron it may be inappropriate to run an Oracle program if Oracle is using the unix username for authentication.
For example when I use root cron to run a script as user "oracle" I use something like this:
Code:
15 20 * * * su oracle -c "/home/oracle/scripts/scriptname"


Tip about cron. Write a one line script and run it once from cron to see the cron environment. Then compare with the the output from "env" in the user environment.
Code:
env >/tmp/cron_env.lst


Footnote:
I can't explain why there were not error messages in mail for the user. If this is a root cron, the errors should be in root mail.
This User Gave Thanks to methyl For This Post:
# 12  
Old 07-16-2010
Please check the right access to the user from which you are trying to spool the data.

1. User must have right access to the directory/mount your are trying to spool into
2. Try to write the error in a log file.

30 18 * * * /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log
# 13  
Old 07-16-2010
Hi all,

sory i was unable to look into solutions....!
Will work on that...
just for info a mail got generated in which said

Code:
/home/fid/AT.ksh[18]  /bin/sqlplus:  not found

will get back to you soon.!
Thanks for replies.

Last edited by Scott; 07-16-2010 at 05:48 PM.. Reason: Code tags
# 14  
Old 07-23-2010
MySQL

Thanks alll........!!!!

my script is now running on server...... Smilie

I didnt understand this.......!!!
Quote:
Tip about cron. Write a one line script and run it once from cron to see the cron environment. Then compare with the the output from "env" in the user environment.


Code:
env >/tmp/cron_env.lst

Also in crontab how to get data in log file, i mean this one

/a/b/file.ksh > fileLog.log

wen i am doin this, no data is comin in fileLog.log, i am givin full path for log file...!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

problem with crontab

hi all does any on has explanation for this result bash-3.00$ crontab -e "/var/tmp/Ex1kayUW" No space left on device The crontab file was not changed. bash-3.00$ (2 Replies)
Discussion started by: osmannix
2 Replies

2. UNIX for Advanced & Expert Users

crontab problem

hi.. i have a program (tf.sh), and i want what it runs automatically with a "lapsus" of 2 hours. (1,3,5,7,9,11,13,15,17,19,21,23 hrs.) i know what i have to do it using crontab, but i donīt know how to do it. i have the next idea, but the problem is what it doesnīt run on my server... (11 Replies)
Discussion started by: DebianJ
11 Replies

3. AIX

Crontab problem

Hi to all. Guys, i have a truble with oracle user crontab. He work if i'm do 0-59 * * * * echo LOL> ~/test.txt But not work if me set realy norm date For example 14 17 28 12 * echo LOL> ~/test.txt In 17:14 28 December . In log file /var/adm/cron/log nothing.... Please... (3 Replies)
Discussion started by: jess_t03
3 Replies

4. Shell Programming and Scripting

Problem in crontab

Hi All, Am facing an issue while updating the crontab.Getting below error while updating the cron. cron/tmp.XXXX5fXBR6: No space left on device crontab: edits left in /tmp/crontab.XXXXEJX5gw Is there any file where i need to alter using root user so that i can update the cron. TIA... (9 Replies)
Discussion started by: Ashok_oct22
9 Replies

5. Shell Programming and Scripting

Crontab Problem

Dear All , I have .sh script wich has the following inside getFileName=Listportfolio.txt.`date +'%Y%m%d` ftp -n 172.10.10.1<<EOF user xxx xxx bin cd /home/gbs/FTP_Script get /home/gbs/FTP_Script/$getFileName bye EOF EOF when I run the... (3 Replies)
Discussion started by: habuzahra
3 Replies

6. UNIX for Advanced & Expert Users

crontab problem

hi all while using crontab -e im receiving 754 as output im unable to add a entry in crontab crontab -l is working fine OS: sun5.8 can some one please assist me (4 Replies)
Discussion started by: NIMISH AGARWAL
4 Replies

7. UNIX for Dummies Questions & Answers

problem with crontab

i added to my crontab file: * * * * * echo "hello" it works, i receive a message into my /var/mail/username and i receive: bob in addition to a large text add-on any help appreciated (1 Reply)
Discussion started by: cleansing_flame
1 Replies

8. UNIX for Dummies Questions & Answers

Problem with crontab

I'm trying to get crontab to run a script, but to test crontab I tried out a very simple command: `echo bob` here is my crontab file (I edited it by using `crontab -e`): ----------------- #!/bin/sh 23 10 * * * echo bob and at 10:23 every day I get a new message: in /var/mail/a... (3 Replies)
Discussion started by: cleansing_flame
3 Replies

9. Shell Programming and Scripting

crontab problem

HI, i am working on linux. i have crontab problem i wrote a small script and put it in a crontab . but the script is not running.. i have given following way in crontab -e 02 06 * * * /bin/csh /home/vr_test.csh but the above script is not running please rectify my... (26 Replies)
Discussion started by: rajan_ka1
26 Replies

10. UNIX for Dummies Questions & Answers

crontab problem

Hi, I trying to include a script in my crontab as user. I used "crontab -e" to include my script there but does not seem to work. If I understand correctly it is set to run at 11:20 every day, correct? Can anybody identify any error? <pre> #Sun Microsystems Inc. SunOS 5.7 Generic... (19 Replies)
Discussion started by: guest100
19 Replies
Login or Register to Ask a Question