There were certainly older UNIX systems for which it was safer to sync more than once, but not all on one command line as "sync; sync; sync". In the mid-80s, this became distilled to:
When thou shuttest down the system, thou shalt
sync three times. No more, no less. Three shall
be the number of the syncing, and the number of
the syncing shall be three. Four times shalt thou
not sync, neither sync twice, except that thou
proceedest to sync a third time...
I don't really know where the three times came from, except maybe that it was fun. But the word on the street to do it twice. Not as "sync; sync", but as two separate lines on the shell.
Back in the days of, say, V7 UNIX, file system repair wasn't much fun. You had to do it by hand, knowing a lot about how the filesystem worked and the idiosyncrasies of programs like dcheck, ncheck, and icheck. fsck, if you had it, wasn't always something you would trust.
This is starting to sound like a "we walked through the snow uphill both ways" story. Well, we didn't have fancy commands like reboot or shutdown. When you wanted to reboot the system, you synced the filesystem with sync, and then you hit Ctrl-P on the console to halt it.
When the sync command exited, the kernel had scheduled the sync, but not all the buffers (including the all-important filesystem superblock) had necessarily made it to the disk. So it was pretty easy to run sync and then halt things before it was safe.
Running sync again was an easy thing to do, took up the time, and had a certain intuitive appeal without having to understand it all, or deal with vague instructions like "count to 10" or something like that.
There was even a BUG section on the V7 man page for update
also said:
With update running, if the CPU is halted just as the sync is executed, a
file system can be damaged. This is partially due to DEC hardware that
writes zeros when NPR requests fail. A fix would be to have sync(1)
temporarily increment the system time by at least 30 seconds to trigger
the execution of update. This would give 30 seconds grace to halt the
CPU.
(which, by the way, was the very last thing in Volume 1 of the V7 manuals)
Over time, the filesystem tools and the programs for shutting down and rebooting systems got better to avoid dealing with this. Folklore, voodoo, and system magic enter into it when the system behaves mysteriously. Syncing twice made it much less likely that you'd have to get out the bit tweezers to put your filesystem back together, so it became part of the ritual. Once you've done it a bunch of times, you do it without thinking. Then someone notices and asks why. And the answer is something like, "Always done it that way. It's safer."
I won't claim that this is authoritative, and I might be wrong about some of the details. But I think it's pretty close to the origin.
sync; sync; sync; sync
in the title, and I do sometimes type it that way, I also heard it explained to me the same way, that is, sync, wait, sync again, wait, etc. – Josh Dec 30 '10 at 22:51