What happens if a cron script tries to copy a directory at the same time as another process is writing to it?
listed in answer
ANSWER:
In general, Unix commands treat files the same, whether they are open and being written to or not. So if a cron job is using cp to copy a directory, what gets copied depends solely on what is in the directory at the time the cp command examines the directory. If a file is only partially written at the time cp visits it, a partially written copy will be produced. If you want to prevent such occurrences, you need to implement a locking scheme amongst cooperating processes to prevent concurrent access to the directory.
by Kyle Jones from http://unix.stackexchange.com/questions/38254

New Comments