Visit Our UNIX and Linux User Community


script dies prematurely and unpredictably


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users script dies prematurely and unpredictably
# 1  
Old 09-29-2009
script dies prematurely and unpredictably

Hi,

I have over 5 gb of data in a files structure in which month folders are in year folders, day folders are in month folders, and individual climate stations are in each day. I am trying to extract precipitation measured at 5 minute intervals for a duration of 15 years, but the script never gets beyond the fifth year. I have run it many many times in Snow Leopard Terminal 2.1 (272). It stops at:
+ echo STIL 89 570 85 13.5 0.7 0.7 137 5.0 0.2 1.0 0.00 -999.00 1 14.4 0.0 15.6 18.2 15.4 16.5 15.8

Here is the script:
#!/bin/ksh -x
Myoutput=/MyOutput/MyOutput_$$.txt
cd ../wine
# takes output of ls command and pass to next line

ls |\

while read nextyear

do
Year=${nextyear}
cd ${nextyear}
ls |\
while read nextmonth
do
Month=${nextmonth}
cd ${nextmonth}
ls |\
while read nextday
do
Day=${nextday}
cd ${nextday}
ls | grep stil | xargs grep -i stil |\
while read nextline
do



Stid=`echo ${nextline} | awk '{print $1}'`
Time=`echo ${nextline} | awk '{print $3}'`
Rain=`echo ${nextline} | awk '{print $12}'`
echo ${Stid} ${Year} ${Month} ${Day} ${Time} ${Rain} >> $Myoutput

done


cd ..
done
cd ..
done
cd ..
done

This is how the output is supposed to look:
STIL 1994 01 01 0 0.00
STIL 1994 01 01 5 0.00
STIL 1994 01 01 10 0.00
STIL 1994 01 01 15 0.00
STIL 1994 01 01 20 0.00
STIL 1994 01 01 25 0.00
STIL 1994 01 01 30 0.00
STIL 1994 01 01 35 0.00
STIL 1994 01 01 40 0.00
STIL 1994 01 01 45 0.00
STIL 1994 01 01 50 0.00
STIL 1994 01 01 55 0.00
STIL 1994 01 01 60 0.00
STIL 1994 01 01 65 0.00
STIL 1994 01 01 70 0.00
STIL 1994 01 01 75 0.00
STIL 1994 01 01 80 0.00
STIL 1994 01 01 85 0.00
STIL 1994 01 01 90 0.00
STIL 1994 01 01 95 0.00
STIL 1994 01 01 100 0.00
STIL 1994 01 01 105 0.00
STIL 1994 01 01 110 0.00
STIL 1994 01 01 115 0.00
STIL 1994 01 01 120 0.00
STIL 1994 01 01 125 0.00
STIL 1994 01 01 130 0.00
STIL 1994 01 01 135 0.00
STIL 1994 01 01 140 0.00
STIL 1994 01 01 145 0.00
STIL 1994 01 01 150 0.00
STIL 1994 01 01 155 0.00
STIL 1994 01 01 160 0.00
STIL 1994 01 01 165 0.00
STIL 1994 01 01 170 0.00
STIL 1994 01 01 175 0.00
STIL 1994 01 01 180 0.00
STIL 1994 01 01 185 0.00
STIL 1994 01 01 190 0.00
STIL 1994 01 01 195 0.00
STIL 1994 01 01 200 0.00
STIL 1994 01 01 205 0.00
STIL 1994 01 01 210 0.00
STIL 1994 01 01 215 0.00
STIL 1994 01 01 220 0.00
STIL 1994 01 01 225 0.00
STIL 1994 01 01 230 0.00
STIL 1994 01 01 235 0.00
STIL 1994 01 01 240 0.00
STIL 1994 01 01 245 0.00
STIL 1994 01 01 250 0.00
STIL 1994 01 01 255 0.00
STIL 1994 01 01 260 0.00

Any ideas? I just need it to run through 10 more years of data!

Thanks!
# 2  
Old 09-30-2009
You may want to

- process the years one by one, than concatenate the filed results;
- go find some freak with a more powerful machine running idle Smilie
# 3  
Old 09-30-2009
Hi,

Please can you run the script in the background and provide us with the details of

Code:
vmstat 2 10

Cheers,
Shazin

Previous Thread | Next Thread
Test Your Knowledge in Computers #382
Difficulty: Medium
HP-UX 11i V3 Release B.11.31 is registered as UNIX V7 compliant.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Xterm dies after being idle

I am running eod8 to connect to a linux machine running carnesr==>uname -a Linux hostname 2.6.32-220.2.1.el6.x86_64 #1 SMP Tue Dec 13 16:21:34 EST 2011 x86_64 x86_64 x86_64 GNU/Linux I have a script that opens up several xterms as follows: /usr/bin/xterm -geometry 150x60+0-0 -name... (1 Reply)
Discussion started by: rcarnesiii
1 Replies

2. Shell Programming and Scripting

[Solved] Process dies when launched in system startup script

Good morning! I'm trying to add Maven to the system boot by the moment without success. Testing the operation of the script I realize that the process isn't persistent when the program is launched with the start option. ---- #Startup Script ---- #! /bin/sh # chkconfig: 345 99 1 #... (5 Replies)
Discussion started by: carpannav
5 Replies

3. Shell Programming and Scripting

Expect script cronjob running but dying prematurely

I have an Ubuntu machine that I'd like to update automatically. I've written an expect script to run the aptitude package manager and update my packages. Essentially it does: aptitude update && aptitude upgrade while answering "yes" at the appropriate time. It works quite nicely when run... (4 Replies)
Discussion started by: CluelessPerson
4 Replies

4. Shell Programming and Scripting

Background program exits prematurely?

Hello! I am currently attempting to build a very, very, basic program that attempts to act like a calendar for a "server." Using this program I need to have the client program connect to the server program, have the client wait for the server to respond through a socket, then exit and the server... (2 Replies)
Discussion started by: Entelexia
2 Replies

5. Infrastructure Monitoring

Nagios escalating prematurely

We are currently using Nagios 1.3 .The issue we facing is , when a alert is in Warning state and then from Warning it moves to Critical state ,the alert is escalated directly to L2,L3 L4 escalations,here nagios assumes that the time period ,the alert was in warning state as unacknowledged time... (0 Replies)
Discussion started by: apatil
0 Replies

6. Programming

nanosleep returns prematurely, with return value 0

Hi, I have encountered the following problem on Solaris 10: I have a thread that is asleep on nanosleep (set to 24 hours). Something that happens on another thread, causes the nanosleep to exit, even though the time has not elapsed. The returned value is 0 (so it doesn't look like it... (1 Reply)
Discussion started by: MeMyself
1 Replies

7. UNIX for Dummies Questions & Answers

perl script dies altogether when I put an & after it

ignore (2 Replies)
Discussion started by: hairytorus
2 Replies

8. Shell Programming and Scripting

script to change default route when primary gateway dies

Hello all! We have two fedora routers one at each site. What we are trying to do worked using freesco but not on fedora, i'm not very good at scripting and need a little guidence. Basicly what we are trying to do is if the primary line dies, the router will change it's routes to go through our... (0 Replies)
Discussion started by: slacker
0 Replies

9. Solaris

daemon dies, need to know why

Say I have a daemon that dies for an unknown reason. Is there a way to track its process ID to try to determine when it dies and what causes it to go away? (2 Replies)
Discussion started by: Silver11
2 Replies

10. Shell Programming and Scripting

Why does rexec cause while loop to end prematurely?

I have the following korn shell script which reads the contents of an ascii file and performs an rexec command based on the line that was just read from the ascii file. The ascii file contains 6 lines, thus, the while loop should execute 6 times. The problem is that the rexec command within the... (2 Replies)
Discussion started by: sadove
2 Replies

Featured Tech Videos