File concurrancy question

From: Rob Snyder (rsnyder_at_reversedthebrokenglass.com)
Date: 12/26/04


Date: Sun, 26 Dec 2004 21:54:00 GMT

All -

I'm still relatively new to many aspects of Linux/unix programming, and
I apologize in advance if this is the wrong place to post this question.
I've tried to discern the answer on my own with no avail.

For sake of discussion, let's say I have a folder on my system, and a
cron job that looks something like:

for i in $(ls /myfolder)
do
   lpr $i && rm -f $i
done

i.e., any syntactic errors aside, scans this folder, printing then
deleting any file therein. Easy enough.

Let's say I'm copying some big ol' file into this directory, and along
comes the cron job to print it. What happens? I'm assuming the file
shows up when the ls command executes, but when it's passed to lpr, it's
going to have only been partially copied. Will I get a printout of half
of the file? Will it get deleted?

It *seems* to do the right thing, but that is more than likely my
testing and not reality. If it isn't going to do the right thing, how do
I ensure consistency, either printing and deleting the whole file or
ignoring it till next pass?

This seems like it should be easy, and I've seen lots of example scripts
that do various things and seem to be implicitly relying on *the right
thing* happening; I just don't see how the proper behavior is enforced
by the OS, or how to enforce it if it isn't.

Thanks, in advance, for any help.

Rob Snyder



Relevant Pages

  • Re: Drag-n-drop
    ... the source rather than by the target of the drag operation. ... that are totally irrelevant to deleting or printing a file. ... that supporting printing & deleting requires a lot of ...
    (comp.os.os2.programmer.misc)
  • Cant print - "Deleting - Printing - Printed" message, no document!
    ... The printer is connected via USB. ... For a time the status says "Printing", ... I can successfully print out a Windows XP test page, ... I've tried deleting and recreating this printer, ...
    (microsoft.public.windowsxp.print_fax)
  • Re: Printing Problems with SBS/XP Pro/HP LaserJet 4050
    ... The user is printing directly directly to a TCP/IP port ... shared from the server, all users would have the same printer driver. ... >>> 4050 over a network all that is printed is a tiny column down the ... >> Have you tried deleting this printer from the user's Windows ...
    (microsoft.public.windows.server.sbs)
  • Re: Project 2000 - cant print
    ... Try deleting the ... printer driver, then re-install it. ... all printing is controlled by the operating system, ...
    (microsoft.public.project)
  • Re: Printing woes -- problem solved
    ... I fixed my problem by going to System> Administration> Printing, deleting ... my printer and setting it up anew. ...
    (Ubuntu)