I have two scripts that watch a directory (postgres warm-standby)
one script copies compressed files into the directory and then uncompresses them.
the other script watches for the uncompressed files and then ingests them into postgres.
Im wondering if i could his a case where the ingestor script could read teh output of gunzip while it was writing it?
in short: does gunzip
- decompress and then change name
- copy into new name as it uncompresses
- something else
It's probably not a good idea to base the correctness of your scripts on assumptions about how a particular utility (such as
gunzip
) works, since the internal behaviour of a utility can change in subsequent releases. I recommend, instead, that you use the proper locking methods (as provided by your particular OS) to ensure mutual exclusion. Most Linux distros provideflock
for use in shell scripts.It is non-atomic, as you can see if you do an ls during a large compression: