Re: run binary executable with . in bash?

From: John Kelly (jak_at_sevenkings.net)
Date: 09/20/04


Date: Mon, 20 Sep 2004 20:12:16 GMT

On 20 Sep 2004 18:38:20 GMT, William Park <opengeometry@yahoo.ca>
wrote:

>Could you not have 2 independent loops,
> - one appending to /.../access, and
> - another calling 'newmailfiles' every 7s
>?
>
>For example,
>
> while sleep 7; do
> newmailfiles
> done &
>
> while read -u 3; do
> echo ... >> /root/local/sendmail/etc.mail/access
> echo ...
> done

You could, but then you wake up every 7 seconds, even if there is no
work to do. And worse yet, you have a race condition where your batch
process may execute when the read loop is still writing to the files
and they are in an incomplete state. My example only shows one file,
but I need a general solution for use in other applications, where I
may write to multiple files.

By blocking on the read and trapping a signal, I sleep indefinitely,
until there is at least one input in the batch, and then wait a short
interval of 7 seconds to see if there might be a burst of input.

That way, I don't repeat the entire batch process separately for each
input (it may be a lengthy process), and the first input opening a new
batch does not wait very long to be processed.

If there is a huge burst of input and the 7 second cutoff starts the
batch process while there is still more input to read, that is not a
problem. Any input not included in the current batch will just stack
up in the FIFO, and when the batch process completes, the read loop
will churn thru the input quickly on the next cycle, including them
all in the next batch, which will be delayed no more than 7 seconds.

And I have no race conditions.



Relevant Pages

  • Re: Batching "fileXXXX.mp3" + "addendum.mp3"... (where XXXX=0001 to 3000)
    ... Obviously this needs to be a batch process, but I cant think of a Wavelab or Soundforge process that would do this offhand. ... On a Windows command prompt or batch file, I think the equivalent would be ...
    (rec.audio.pro)
  • Broke file Warning
    ... I have a batch process that run at night using some ... Excel document that excel open during the process. ... How may i disable this warning, because when the batch run ...
    (microsoft.public.office.misc)
  • Batch functionality
    ... Any suggestions on best practices on implementing batch process ... functionality in a web app? ... The idea is to run a batch of order processing at night when the site load ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: SENDKEYS on Locked Machine
    ... you can not unlock a computer from a batch or script. ... Can i unlock it and run the batch process? ...
    (microsoft.public.scripting.wsh)
  • RE: SENDKEYS on Locked Machine
    ... you can not unlock a computer from a batch or script. ... Can i unlock it and run the batch process? ...
    (microsoft.public.scripting.vbscript)