Sample Header Ad - 728x90

cp options --no-clobber vs. --update

4 votes
2 answers
10277 views
I want to copy a single file if (and only if) the destination does not exist. The source file changes rarely, maybe once a month. The destination almost never exists. Are there any differences between the -n and -u options? (Or both!) cp is being called directly from crond. No othercp options are used. The same cron job is called on several machines at the same time, reading from the same source and writing to the same destination (both on a shared GFS global file system). The destination file will be moved shortly thereafter by another process, so the only time it could exist is during the race when the cron job executes simultaneously on several nodes. Which would be more efficient? : * cp -n source dest * cp -u source dest * cp -nu source dest * cp -pu source dest I'm currently leaning towards the simple -n alternative.
Asked by MattBianco (3806 rep)
May 4, 2015, 11:14 AM
Last activity: Feb 22, 2025, 08:18 AM