Issue with crontab output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Issue with crontab output
# 1  
Old 01-26-2010
Issue with crontab output

Hi ,
I have this crontab job which is not able to write a db2 command output to a file . The output file comes out to be of file zero and it sends me wrong alerts .
Code:
cat indoubt_transaction.shl

#!/bin/ksh
PATH=/usr/bin::/jcw-data/home/jcwprodi/sqllib/bin:/jcw-data/home/jcwprodi/sqllib/adm:/jcw-data/home/jcwprodi/sqllib/misc:/bin
DB2INSTANCE=jcwprodi
LD_LIBRARY_PATH=:/usr/lib:/usr/sbin:/usr/bin:/lib
export PATH DB2INSTANCE

db2 -x  "connect to ATG "

db2 -x  " list indoubt transactions "  > /jcw-data/jcwprodi/CRONTAB/indoubt_transaction.out

chmod 755 /jcw-data/jcwprodi/CRONTAB/indoubt_transaction.out

trns_state=`cat /jcw-data/jcwprodi/CRONTAB/indoubt_transaction.out | grep -i data  | awk '{print $1}'`

  if [ $trns_state = 'SQL1251W' ]
     then
       echo " No Indoubt Transaction "  |  mail -s " NO INDOUBT Transaction  " abc@gmail.com
     else
     echo " There is Indoubt Transaction on ATG" |   mail -s " Indoubt Transaction on ATG " abc@gmail.com
fi

When I run this file as simple sh -x , it works fine . I don't know where am I wrong .

Any suggestions folks ,
Thanks

Last edited by Scott; 01-26-2010 at 02:21 PM.. Reason: Code tags, PLEASE!
# 2  
Old 01-26-2010
Don't use "naked" commands like chmod and db2. Give fully specified pathnames for the
command: e.g.,
Code:
/usr/bin/chmod 
/path/to/db2

your contrab entry should look something like this:
Code:
0 10 ** 1,2,3,4,5 /path/to/indoubt_transaction.shl 2&>1 > /path/to/logfile.log

Which will help you see where errors occur as well.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Crontab issue

Hello, I have a bash script that finds files older than 31 days and deletes them. I have this file loading into crontab to run everyday. It ran fine the first time i loaded it in, but now when I try to run it manually (bash file.sh) I get errors. Here is the script TIME=" -maxdepth 1... (6 Replies)
Discussion started by: jrymer
6 Replies

2. UNIX for Advanced & Expert Users

Crontab Issue

My colleague who was a sysadmin , has created a cron job script which collects logs and process them. The script works perfectly as per the defined time set by him. it works when we keep the timing as 55 05 * * * , whereas if we try to prepone the cron task is not getting executed. Where... (10 Replies)
Discussion started by: aravindj80
10 Replies

3. Shell Programming and Scripting

Crontab issue

hi, i have schduled a job through crontab, but it is not getting executed. bash-3.2$ crontab -l # Monthly Download (mm hh DD MM format) 35 05 01 04 * /home/ftpsrp/srpftp1/download/ofrdb/scripts/load_ofrdb.sh crr.sh here is the permission of the .sh files -rwxr--r-- 1 ftpsrp srp ... (7 Replies)
Discussion started by: lovelysethii
7 Replies

4. UNIX for Dummies Questions & Answers

Crontab Issue..!!!

Hi, I have a cronjob but it is not getting executed.Is there any ways to check whether crontab is working.I have put crontab -l and checked.It got listed.But it is not working. My Crontab is, * * * * * /ldesk/home/abc/source/compare.sh >/dev/null 2>&1 (1 Reply)
Discussion started by: gayisada
1 Replies

5. AIX

Crontab issue

Hi all, I'm having a problem with a crontab entry execution for a non root user. AIX version 5.3 user@host ~ $ oslevel -r 5300-10 cron status user@host ~ $ ps -ef | grep cron root 377044 1 0 Oct 27 - 0:22 /usr/sbin/cron cron entry for user user@host ~ $... (3 Replies)
Discussion started by: h@foorsa.biz
3 Replies

6. Shell Programming and Scripting

Issue with redirecting output from crontab

Hello All, I've scheduled one simple command to be run from crontab, but the command is failing to append the output to a file. Any issue in my syntax ? This rah cmd is working fine from command center. 19 09 * * * rah "df -m" | awk '{if (NF > 1) if ($5 ~ /NODE/) {print $0;}}' >> db.out 2>&1... (1 Reply)
Discussion started by: NARESH1302
1 Replies

7. Shell Programming and Scripting

crontab issue

Helo . I have 2.6.13-1.1526_FC4smp here. I am trying to make crontab execute my simple shell script, but noting happens. here is how i am testing this : $ pwd /home/oracle $ ls -l two* ls: two*: No such file or directory $ $ crontab -e crontab: installing new crontab $ $ crontab... (7 Replies)
Discussion started by: tonijel
7 Replies

8. Shell Programming and Scripting

crontab issue

Hi Guys, I am having a prob with crontab.. When i enter "crontab -e", i am getting an message "History file has no read permission. " And my crontab is not executed (means the script is not called). What is the problem. can anybody help me.. Thanks for the help in advance.. ... (2 Replies)
Discussion started by: mac4rfree
2 Replies

9. UNIX for Advanced & Expert Users

crontab issue

I am adding a piece of code which adds entry in crontab ((in brown color)) \crontab -l > $tmpfile echo "Removing the cleanProcess entry if it already existed.." grep -v "cleanProcess.sh" $tmpfile > $newtmpfile lcnt=`grep -c "cleanProcess.sh" $tmpfile` echo... (4 Replies)
Discussion started by: crackthehit007
4 Replies

10. HP-UX

crontab issue

Dear Folks, i am new to hp-ux, i have a problem scheduling the crontab, The script is working fine at command prompt, but not working at cron, please find a solution for it , here are the logs and my schedule at cron: log after restarting crontab /var/adm/cron/log ! *** cron started *** ... (11 Replies)
Discussion started by: vaddi
11 Replies
Login or Register to Ask a Question