Visit Our UNIX and Linux User Community


error in file writing in crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting error in file writing in crontab
# 1  
Old 10-02-2009
error in file writing in crontab

Hi ,
I have a crontab job that is trying to write a file and the read it . But the crontab is not able to create any file . But when i run the script as shell then it runs fine . could you tell me what i am missing here .

Here is the script

cat Tablespace_Monitor_ATG

#!/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 "drop table daya.tablespace_info "

db2 -x "create table daya.tablespace_info ( Tblsp_name varchar(15) , size_in_mb bigint ,Per_free_space int, used_size_mb bigint )"

db2 -x "select tablespace_name , int((total_pages*page_size)/(1024*1024)) as Size_in_MB ,smallint((float(free_pages) / float(total_pages))*100) as per_free_space, int((used_pages*page_size)/(1024*1024)) as Used_size_MB from table(SNAPSHOT_TBS_CFG('ATG',-1)) where tablespace_type=0 "

db2 -x "insert into daya.tablespace_info select tablespace_name , int((total_pages*page_size)/(1024*1024)) as Size_in_MB ,smallint((float(free_pages) / float(total_pages))*100) as per_free_space, int((used_pages*page_size)/(1024*1024)) as Used_size_MB from table(SNAPSHOT_TBS_CFG('ATG',-1)) where tablespace_type=0 "

echo "TABLESPACE NAME % FREE SPACE" > Tablespace_info_atg
echo " " >> Tablespace_info_atg
db2 -x "select TBLSP_NAME as Name ,PER_FREE_SPACE as Percentage_use from daya.tablespace_info" > Tablespace_info_atg
# It is failing to create the above file Tablespace_info_atg
chmod 777 Tablespace_info_atg
cat /jcw-data/jcwprodi/CRONTAB/Tablespace_info_atg | mail -s "Tablespace Usage For ATG on WAG-PROD-DBCLUSTER " abc_123@yahoo.com

Thanks in advance
# 2  
Old 10-02-2009
1. Post the code with code tags for proper visibility.

2. Thing you may miss is, Give the filename with Absolute Path.

3. Dont miss to check FAQ here.
# 3  
Old 10-02-2009
I tried to run the same script as higher id ( id added to sudoer file ) and that works fine .
It worked when i had /tmp as the path before i wrote the full path too .

Thanks , it works now Smilie

Previous Thread | Next Thread
Test Your Knowledge in Computers #779
Difficulty: Medium
Spectrum analysis is also referred to as time domain analysis or time density estimation.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - writing matching pattern to a new file and deleting it from the current file

Hello , I have comma delimited file with over 20 fileds that i need to do some validations on. I have to check if certain fields are null and then write the line containing the null field into a new file and then delete the line from the current file. Can someone tell me how i could go... (2 Replies)
Discussion started by: goddevil
2 Replies

2. Shell Programming and Scripting

while writing the script getting an error

while writing a script m not able to convert string into a number therefore it is not picking the write if condition pls help #!/bin/sh echo "this game is about selecting number and getting lucky" echo " the number are 1 2 3 4 5 and 0 to exit" read $a1 if ; then echo "NUMBER... (7 Replies)
Discussion started by: ripudaman.singh
7 Replies

3. Programming

Getting compilation error while writing standalone for ddi_get8

Hi All, I have already posted a thread regarding ddi_regs_map_setup solaris system call guidance. https://www.unix.com/programming/171907-need-guidance-using-ddi_regs_map_setup-solaris-system-call.html I am writing a standalone to use this system call. Below is my partial standalone... (6 Replies)
Discussion started by: vijayrajen
6 Replies

4. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

5. HP-UX

DVD writing I/O Error on HP-UX

Hello, when I executed this command: root@server:/opt/ignite/lbinia> growisofs -Z /dev/rdsk/c1t2d0=/PA.iso I get the following output and error: Executing 'builtin_dd if=/PA.iso of=/dev/rscsi/c1t2l0 obs=32k seek=0' :-: I/O error Anyone have any idea what is happeneing? Here is... (1 Reply)
Discussion started by: LinuxRacr
1 Replies

6. UNIX for Advanced & Expert Users

Crontab Error - creating zero byte log file

Hi, I am trying to run a shell script using the crontab scheduler, and I am redirecting the log of the script output to some temp log file using the following command. sh somescript.sh 1> /location/somefile.log Evrytime the cronjob triggers this script, It creates a zero byte file in the... (4 Replies)
Discussion started by: DSDexter
4 Replies

7. Shell Programming and Scripting

Writing to standard error

Hi, I want to redirect the standard output to standard error whenever an error occurs for ex if then echo right else echo wrong fi I want to redirect the wrong to stderror .Adding a line 1>&2 will do that or is additional code to be added.How can i verify whether the output... (2 Replies)
Discussion started by: padmisri
2 Replies

8. Shell Programming and Scripting

Run perl file in Crontab error.

Hi. I can run the script okay when I log in with root. Then I add this script to crontab and when crontab run i got this message error. I has installed DBD for Oracle already. I set ORACLE_HOME, ORACLE_BASE to root profile already. Please help me to fix it. It urgent. Thank so much. ... (2 Replies)
Discussion started by: raccsdl
2 Replies

9. Shell Programming and Scripting

Crontab error Cannot execute binary file.

Anyone can help me ? I try to using crontab with a simple shell script as echo it run okay but now i have more command in script. when I set entry to crontab and whe it run i get mail with error cannot execute binary file. it urgent so please help me the soutions. Thank so much for your help.... (5 Replies)
Discussion started by: raccsdl
5 Replies

10. UNIX for Dummies Questions & Answers

Writing to Standard Error

Hi. I'm working on a project for a class, and there's one part of the project that is confusing me. It's a compression and decompression project, and after we write our code for compression, we need to write to standard error. (1) Size of original file (number of characters read... (1 Reply)
Discussion started by: sjung10
1 Replies

Featured Tech Videos