1 thought on “sync — The command you never heard of

  1. I loved reading today’s article about the sync command! I always use sync when running backups. To make a backup, I use rsync (unrelated, despite similar name) to copy my $HOME to an external USB drive, then run sync to force the system to flush the buffers. Using sync to flush the system buffers means I don’t have to wait as long when unmounting the USB drive, because I usually run it like this:

    $ date ; rsync -a $HOME/ /path/to/backup/ ; date ; sync ; date

    (Once I see the third timestamp printed, I know using umount won’t take too long.)

    I noticed David uses two sync commands. From my RHEL days, I remembered when we learned about the sync command. Out of habit, I typed it three times. The trainer asked if I had learned Unix on Sun systems (I did; my first job was maintaining a network of Apollo and SunOS systems).

    She said you can usually tell where a person learned their first Unix by how many times they ran the sync command: 2 times, it was probably AIX or HP-UX. 3 times, it was probably SunOS. But she said Linux does it better, you only need to run sync just once.

    In more recent years, I learned that the number of times you run sync is more likely based on whether your system was tape-based. Running sync once flushed the buffers; but 2 or 3 times (depending on the system) would also force the system to rewind the tape. And yes, the Apollo and SunOS systems I maintained in the mid 1990s were all tape-based, and you installed the OS and updates from QIC tape.

Leave a Reply