Throttling


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Throttling
# 1  
Old 04-21-2008
Throttling

Hey guys,

Need your help/suggestions

I have a log file which has 5K lines in it, I need to send only 200 lines to an application at a time and delete the 200 lines from log fileafter its been fed to application.

The script should keep on running until all 5K has been processed..

Help????
# 2  
Old 04-21-2008
If the log file might still grow while you are handling it, doing this in a shell script sounds rather dangerous. From Perl or Python or C, you might be able to use some file locking primitives to coordinate with processes which might be writing to the file concurrently.

Having said that, consider this (lack of) proof of concept.

Code:
while true; do
  if head -n 200 file | xargs application; then
    sed 1,200d file >file.tmp
    mv -f file.tmp file
    test -s file || break  # quit loop if file empty
  else
    echo "application failed ($?); not removing first 200 lines -- retrying in a while" >&2
  fi
  sleep 600 # or something like that here, maybe?
done

# 3  
Old 04-22-2008
working partially

Hi era,

I am getting this error...

sed: can't read requests1: No such file or directory

Code is like this

while true; do
if head -n 500 requests1 > /app//reqs.txt;cd /f/app/Rp/bin
./sApp;
then
sed 1,500d requests1 > reqs.tmp
mv -f reqs.tmp requests1
test -s requests1 || break
else
echo "error";
fi
sleep 2000
done
rm requests1
else
echo " Please try later!! "
exit 0
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Red Hat

Throttling a Yum Mirror sync

I'm building a yum mirror on Oracle Enterprise Linux, which is a fork of RHEL. I'm using uln-yum-mirror to create and maintain the mirror. In the Yum client, more specifically in /etc/yum.conf there is a throttle setting. Is there a like feature in /etc/sysconfig/uln-yum-mirror? If so, what is... (0 Replies)
Discussion started by: os2mac
0 Replies

2. Solaris

Solaris sftp throttling?

I get poor performance when sftp'ing a file to a server on a SunOS 5.10 system, with Sun_SSH_1.1.4. The same client performs much better to a linux system at the same site. From a TCPdump, it appears that the Solaris server is throttling the thruput. After proceeding normally for a while, the... (0 Replies)
Discussion started by: AGermain
0 Replies

3. UNIX for Advanced & Expert Users

Interrupt storm detected on "irq 20" throttling interrupt source

I receive the following warning messages on a very new machine which has FreeBSD 8.1 x64 installed on it: Interrupt storm detected on "irq 20" throttling interrupt source It is unclear what this means and what its origins are (motherboard? CPU? RAM?). I can start the desktop and the message is... (4 Replies)
Discussion started by: figaro
4 Replies

4. UNIX for Advanced & Expert Users

Throttling Process Resource Consumption

Is there a way of throttling a process resources, something akin to limits but for processes not users? ie I want processX to be restricted in the amount of memory it can consume. For process cpu I guess I can simply nice the process, but total memory consumption is my primary concern. (3 Replies)
Discussion started by: humbletech99
3 Replies
Login or Register to Ask a Question