Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

why three syncs?

825 views
Skip to first unread message

Brian Ellis

unread,
Sep 4, 1991, 6:57:26 PM9/4/91
to
In article <1991Sep04.1...@uvmark.uucp>, t...@uvmark.uucp (Tom Rauschenbach) writes:
|> I've noticed that most Un*x folks type the sync command three times before
|> shutting down a system. Is there a folkloric reason for this ? A technical
|> one. I have a guess, and I wonder if it can be confirmed or refuted.

Quoting from sync(2) from the Ultrix 4.1 man pages...

The sync system call causes all information in memory that should
be on disk to be written out. This includes modified super-
blocks, modified i-nodes, and delayed block I/O.

Programs that examine a file system, for example, fsck or df, use
the sync system call. The writing, although scheduled, is not
necessarily complete upon return from sync.

The second sentence of the second paragraph suggests why three syncs are
required before shutting down a Unix system.

Brian.

--
Brian Ellis Computing Services Centre
Domain: Brian...@vuw.ac.nz Victoria University of Wellington
Bang paths... grrrr!!!!! P.O Box 600, New Zealand.
What! - no cute .sig ???

Alan J Rosenthal

unread,
Sep 4, 1991, 8:01:44 PM9/4/91
to
t...@uvmark.uucp (Tom Rauschenbach) writes:
>I've noticed that most Un*x folks type the sync command three times before
>shutting down a system. Is there a folkloric reason for this ? A technical
>one.

One for me, one for thee, and one for the pot!

As others have remarked, it's not the case that when you get your prompt back,
the disks have been synced. Old-time unix folks tell me that the correct
method is to type sync once, then listen or watch for the disk, and wait until
it stops. I suppose that the extra two syncs give you something to do while
waiting.

I heard a theory that the first sync schedules the writing, and that the second
sync won't return until the writing actually scheduled by the first sync is
completed, but I'm very sure that this is false. It wouldn't explain why
people do three or more, anyway.

ajr

p.s. !@#$%^& a/ux usually gets fsck errors upon the next boot no matter WHAT
you do, but it's abnormal.

Dirk Grunwald

unread,
Sep 4, 1991, 7:54:23 PM9/4/91
to

i remember seeing a snippet somewhere

% sync
% sync
% sync ## in case of skidding

i think it's folklore.

Tom Rauschenbach

unread,
Sep 4, 1991, 3:48:22 PM9/4/91
to
I've noticed that most Un*x folks type the sync command three times before
shutting down a system. Is there a folkloric reason for this ? A technical
one. I have a guess, and I wonder if it can be confirmed or refuted.


--
Tom Rauschenbach "I see nobody on the road," said Alice.
"I only wish I had such eyes," the King remarked in a fretful tone. "To be
able to see Nobody ! And at that distance too !" ..uunet!merk!uvmark!tom

Frederick M. Avolio

unread,
Sep 4, 1991, 10:36:51 PM9/4/91
to

Bah! I've been typing 3 syncs for...11 or 12 years. It's not folklore.


It's Tradecraft.

:-)

F

Steven M Kosloske

unread,
Sep 4, 1991, 5:42:31 PM9/4/91
to
In article <1991Sep04.1...@uvmark.uucp> t...@uvmark.uucp (Tom Rauschenbach) writes:
>I've noticed that most Un*x folks type the sync command three times before
>shutting down a system. Is there a folkloric reason for this ? A technical
>one. I have a guess, and I wonder if it can be confirmed or refuted.
>
>

I'm not sure about other UNIX admin's, but I got started doing three sync
commands because that was what was suggested in the SCO Xenix manual.

In reality, all you should need is one, but better safe then sorry, we
run three. I've seen some do more than three before a shutdown. Want to
be sure that everything is closed and written to disk before powering
down a Unix system.


--
(Steve Kosloske) | "A year working in Artificial
------------------------------------| Intelligence is enough to make
Internet: za...@csd4.csd.uwm.edu | one believe in God." -
UUCP: uunet!za...@csd4.csd.uwm.edu | Alan Perlis

Greg Lehey

unread,
Sep 5, 1991, 3:40:58 PM9/5/91
to

It's superstition, mistrust and function of your typing speed. I always do four.

So-nice-so-nice-we-do-it-twice-twice-ing you what
Grog

Tom Ploegmakers

unread,
Sep 5, 1991, 4:01:53 AM9/5/91
to
In article <1991Sep04.1...@uvmark.uucp> t...@uvmark.uucp (Tom Rauschenbach) writes:
>I've noticed that most Un*x folks type the sync command three times before
>shutting down a system. Is there a folkloric reason for this ? A technical
>one. I have a guess, and I wonder if it can be confirmed or refuted.

The reason i know for doing more than a single sync is that sync
is performed asynchonously by the kernel. When the command
returns the sync operation is not yet finished. So If you halt
immediatly after that you would still have incorrect filesystems
on disk. When memories were small the sync would be completed by
the time you had typed anything, so why not a second sync?

A second sync would not make your filesystems any better because
there will not be found any blocks in the buffer cache that need
syncing.

When memories, and buffer caches, grew bigger this was no
guarantee anymore. I heard about a Convex that spend tens of
seconds syncing after doing lots of installaion work single user.
Modern unixes, at least bsd's, always sync when you halt them,
even when they panic. But i still have the old sync, sync, jalt
on my fingertips.


tom ploegmakers NIKHEF/K-CSG (t...@nikhefk.nikhef.nl)

po.box 4395, 1009 AJ Amsterdam, the Netherlands.
phone: -31 20 5922035

Jose Pina Coelho

unread,
Sep 5, 1991, 6:11:09 AM9/5/91
to

In article <1991Sep4.2...@uwm.edu> za...@csd4.csd.uwm.edu

(Steven M Kosloske) writes:
I'm not sure about other UNIX admin's, but I got started doing three sync
commands because that was what was suggested in the SCO Xenix manual.

In reality, all you should need is one, but better safe then sorry, we
run three. I've seen some do more than three before a shutdown. Want to
be sure that everything is closed and written to disk before powering
down a Unix system.


From the ultrix manual pages:

Name: sync(1) - update the super block
Description:
The sync command executes the sync system primitive. The sync
command can be called to insure all disk writes have been com-
pleted before the processor is halted in a way not suitably done
by reboot(8) or halt(8).

See sync(2) for details on the system primitive.


Name: sync(2) - update super-block
Description:


The sync system call causes all information in memory that should
be on disk to be written out. This includes modified super-
blocks, modified i-nodes, and delayed block I/O.

[...]

# The writing, although scheduled, is not
# necessarily complete upon return from sync.

This last paragraph is the important one. The first sync only asks
the system to start flushing the cache, so, you need a certain time
for the cache to be clear.
The next two syncs are called to give the system time to flush.

--
Jose Pedro T. Pina Coelho | BITNET/Internet: j...@fct.unl.pt
Rua Jau N 1, 2 Dto | UUCP: ...!mcsun!unl!jpc
1300 Lisboa, PORTUGAL | Home phone: (+351) (1) 640767

Sex is not the answer. Sex is the question. "Yes" is the answer.

Frank Wortner

unread,
Sep 5, 1991, 9:45:44 AM9/5/91
to
The sync forces a write to the physical disk, and this takes a certain
amount of time. Back in the days of ASR33s, it took a fairly significant
amount of time to type "sync" three times because one had to litterally
pound on the tiny cynlindrical keys. Most people thought that the
amount of time necessary to type three sync commands was sufficient
for the system to flush its buffers to disk.

Either that, or three is just a nice number. Afterall, there are three
stooges, three (talented) Marx brothers --- few people remember
Zeppo, and even fewer have even *heard* of Gummo ---, three branches
of government in the US, three ... ;-)

Frank

Eric Dittman

unread,
Sep 5, 1991, 5:07:19 PM9/5/91
to
In article <1991Sep4.2...@jarvis.csri.toronto.edu>, fl...@dgp.toronto.edu (Alan J Rosenthal) writes:
> p.s. !@#$%^& a/ux usually gets fsck errors upon the next boot no matter WHAT
> you do, but it's abnormal.

I used to have this problem with A/UX. I tracked the problem down to
a bad SCSI cable. Since replacing the cable, I haven't had any problems
even with one blackout, three resets after panics, and several shutdowns.
--
Eric Dittman
Texas Instruments - Component Test Facility
dit...@skitzo.csc.ti.com
dit...@skbat.csc.ti.com

Disclaimer: I don't speak for Texas Instruments or the Component Test
Facility. I don't even speak for myself.

Peter Lamb

unread,
Sep 5, 1991, 5:10:59 PM9/5/91
to
fr...@croton.nyo.dec.com (Frank Wortner) writes:

>Either that, or three is just a nice number. Afterall, there are three
>stooges, three (talented) Marx brothers --- few people remember
>Zeppo, and even fewer have even *heard* of Gummo ---, three branches
>of government in the US, three ... ;-)

"What I say three times is true"

The Bellman, "The Hunting of the Snark", Lewis Carroll


--
Peter Lamb (p...@iis.ethz.ch)
Integrated Systems Laboratory
ETH-Zentrum, 8092 Zurich

Dave Mankins

unread,
Sep 5, 1991, 4:41:48 PM9/5/91
to
Lewis Carroll in _Hunting of the Snark_ writes:
> What I tell you three times is true.

--
david mankins (d...@think.com)

John Dodson

unread,
Sep 6, 1991, 1:19:25 AM9/6/91
to
I thought it was...

"sync three times on the console if you want me"

;-)

John Dodson, Dept of Physiology,
jo...@physiol.su.oz.au University of Sydney,
Phone +61-2-692-3277 NSW 2006
Fax +61-2-692-2058 Australia.

John Whitmore

unread,
Sep 6, 1991, 1:45:26 AM9/6/91
to
In article <1991Sep5.2...@Think.COM> d...@think.com writes:
(replying to the query about why repeat 'sync' thrice)

>Lewis Carroll in _Hunting of the Snark_ writes:
> > What I tell you three times is true.

Oh, give the full verse!

"Just the place for a snark," the bellman cried
as he landed his crew with care,
supporting each man at the tip of the tide
with a finger entwined in his hair.

"Just the place for a snark!
I have said it twice:
that alone should encourage the crew.

"Just the place for a snark.
I have said it thrice!
What I tell you three times, is TRUE!"


so if you were wondering why the original enquiry had the keyword
'bellman' (as did all the followups), this is why.

These are the opening lines to Lewis Carroll's _The
Hunting of the Snark_, of course.

John Whitmore

Message has been deleted

Christopher Samuel

unread,
Sep 6, 1991, 8:03:33 AM9/6/91
to
In article <1991Sep04.1...@uvmark.uucp>
t...@uvmark.uucp (Tom Rauschenbach) doodled:

> I've noticed that most Un*x folks type the sync command three times before
> shutting down a system. Is there a folkloric reason for this ? A technical
> one. I have a guess, and I wonder if it can be confirmed or refuted.

The reason I remember dates back to when disks were slower than they are
today (they don't make 'em like they used to :-] ), the first sync was
to actually sync the disks, the others were to delay the operator from
powering down until the disks were finished with.

Obviously, for this to work as intended, the filesystem had to be
quiescent, so you'd have to boot all the users off and stop new ones
logging in.

Hence shutdown and /etc/nologin...

- Chris

--
Christopher Samuel| RFC: cc...@aber.ac.uk ALTERNATE: csa...@nyx.cs.du.edu
c/o Physics Dept.,| JNT: cc...@uk.ac.aber UUCP: *!mcsun!ukc!aber!ccs7
UCW Aberystwyth, +----------------------------------------------------------
Aberystwyth, WALES| Disclaimer: I mean nothing I say, and say nothing I mean.

Steven M. Stadnicki

unread,
Sep 6, 1991, 12:19:19 PM9/6/91
to
>Either that, or three is just a nice number. Afterall, there are three
>stooges, three (talented) Marx brothers --- few people remember
>Zeppo, and even fewer have even *heard* of Gummo ---, three branches
>of government in the US, three ... ;-)

"Three is a magic number, yes it is; it's a magic number"
I ought to dig around for the lyrics when I get home; haven't heard it in a
while...

Steven Stadnicki
ss...@andrew.cmu.edu
"Anybody want a used cat?"

Tom Rauschenbach

unread,
Sep 6, 1991, 2:04:23 PM9/6/91
to
In article <1991Sep5.2...@Think.COM> d...@think.com writes:
Yes! This is exactly what I was alluding to, but judging from the responses
so far, this must not be behind the three syncs. I was just speculating
that it might be, now I'm convinced that it's not. I guess we can all go back
to debating if "foo" comes from "FUBAR".

Russell E. Button

unread,
Sep 6, 1991, 8:32:42 PM9/6/91
to
Sync, Sync, Sync...

Isn't that a tune that Benny Goodman used to play?


Russ Button
but...@alc.com

young a t

unread,
Sep 8, 1991, 7:05:03 PM9/8/91
to
In article <Iclue7600...@andrew.cmu.edu> ss...@andrew.cmu.edu (Steven M. Stadnicki) writes:
...

>"Three is a magic number, yes it is; it's a magic number"

In graduate school, someone pointed out that:

1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040, the constant in the Saha equation -- proving once again that 7
is a magic number!
--
--

A.T.Young, Astronomy Department, San Diego State University, San Diego CA 92182

Gordon Burditt

unread,
Sep 7, 1991, 6:29:59 AM9/7/91
to
>The sync forces a write to the physical disk, and this takes a certain
>amount of time. Back in the days of ASR33s, it took a fairly significant
>amount of time to type "sync" three times because one had to litterally
>pound on the tiny cynlindrical keys. Most people thought that the
>amount of time necessary to type three sync commands was sufficient
>for the system to flush its buffers to disk.

Using a Decwriter console on a PDP/11 (/45 or /70), it was very easy
to type:

# sync<DEL>

by accident, because DEL and RETURN were close to each other.
DEL was the interrupt character. Using 3 sync's made it more
probable that at least one of them was terminated by RETURN and
actually got executed. I don't know whether that had anything to
do with the "3 syncs" advice.

Gordon L. Burditt
sneaky.lonestar.org!gordon

Win Treese

unread,
Sep 8, 1991, 3:42:07 PM9/8/91
to

Book of Wizards, chapter 5, verse 7:

"And thou shalt sync, counting to three,
And three shall be the number of the syncing,
And the number of the syncing shall be three.
Thou shalt not sync twice, except as thou proceedest directly to sync
a third time,
Nor shall thou sync four times.
Five is right out."

Win Treese Cambridge Research Lab
tre...@crl.dec.com Digital Equipment Corp.
(with apologies to Monty Python)

J. Horsmeier

unread,
Sep 9, 1991, 6:45:07 AM9/9/91
to

No, no, no .. That was `I'm syncing in the rain' 8^)

Jos


|_Jos_Horsmeie...@and.nl_| J.F. Kennedy `Ich bin ein Berliner' |
| O O \O/ O O \O | R. Nixon `I am not a crook' |
|<|> <|/ | <|> \|> |> everybody | R. Reagan `I uhhh ...' |
|/ \ / / \ / \ \ / \ twist! | G. Bush `I don't like broccoli' |
| Zappa for president of the USA | F. Zappa `I am a Hamburger' |

Frank Zsitvay

unread,
Sep 9, 1991, 5:32:32 AM9/9/91
to
In article <39...@datum.nyo.dec.com> fr...@croton.nyo.dec.com writes:
>The sync forces a write to the physical disk, and this takes a certain
>amount of time. Back in the days of ASR33s, it took a fairly significant
>amount of time to type "sync" three times because one had to litterally
>pound on the tiny cynlindrical keys. Most people thought that the
>amount of time necessary to type three sync commands was sufficient
>for the system to flush its buffers to disk.

This is pure speculation, since I'm not a *nix wizard...

But perhaps, the line of thought was as such...

The first sync begins writing buffers to disk if they have changed. It
spawns the process that does this, and returns a prompt to the suser...

The second one then repeats the process, and takes time to be typed
into the shell...

By the time you type the third one, most buffers have been written to
disk. If everything goes properly, the only buffer that has to be checked
is the one that was openned by the shell when it was retrieving sync from
the disk.

Again, pure speculation. Perhaps it reflects the idea "when in doubt,
use brute force..."

Out of curiosity, wouldn't it be possible to write sync in such way
that it would not terminate until all buffers were either checked or
flushed??


--
fzsi...@techbook.COM - but don't quote me on that....

According to a reputable source, 'glastnost' translated from Russian
really means 'lesser grade of barbed wire.'

Steve Lamont

unread,
Sep 9, 1991, 12:45:49 PM9/9/91
to
In article <14...@baby.and.nl> j...@and.nl (J. Horsmeier) writes:
>In article <1991Sep7.0...@alc.com> but...@alc.com (Russell E. Button) writes:
>|Sync, Sync, Sync...
>|
>|Isn't that a tune that Benny Goodman used to play?
>No, no, no .. That was `I'm syncing in the rain' 8^)

... I'm getting syncing feelings about this.

spl (the p stands for
puns)

--
Steve Lamont, SciViGuy -- (619) 534-7968 -- s...@dim.ucsd.edu
UCSD Microscopy and Imaging Resource/UCSD Med School/La Jolla, CA 92093-0608

Dana H. Myers

unread,
Sep 10, 1991, 5:56:40 PM9/10/91
to
In article <1991Sep8.1...@crl.dec.com> tre...@crl.dec.com (Win Treese) writes:
>
>Book of Wizards, chapter 5, verse 7:
>
>"And thou shalt sync, counting to three,
> And three shall be the number of the syncing,
> And the number of the syncing shall be three.
> Thou shalt not sync twice, except as thou proceedest directly to sync
> a third time,
> Nor shall thou sync four times.
> Five is right out."

Of course, this was first written in the instructions for the
Holy Hand Grenade, from _Monty Python's Holy Grail_....


--
* Dana H. Myers KK6JQ | Views expressed here are *
* (213) 337-5136 | mine and do not necessarily *
* da...@locus.com | reflect those of my employer *

John Winters

unread,
Sep 10, 1991, 11:31:23 AM9/10/91
to
Just ask Larwence of aWelkia:

A one..
and a two..
and a three..

(besides, most programmers are bored counting to numbers larger than
three...)

--
John Law Winters Office: (813) 530-2614 voice
8390 Parkwood Blvd. Home : (813) 391-1047 voice
Largo, Florida 34647 email: win...@pdn.paradyne.com

Win Treese

unread,
Sep 10, 1991, 11:11:32 PM9/10/91
to

Plagiarism being a hot topic in the news these days, I note that at the
end of the message was the note:

"With apologies to Monty Python"

Should this fail to satisfy the net.community, I shall only provide
full bibliographic references in extremely detailed footnotes in the
future.

young a t

unread,
Sep 10, 1991, 9:34:58 PM9/10/91
to
...

> Again, pure speculation. Perhaps it reflects the idea "when in doubt,
>use brute force..."

No, that's "If brute force does not work, you are not using...


... enough."

--

A.T.Young, Astronomy Department, San Diego State University, San Diego CA 92182

a...@ucselx.sdsu.edu or a...@mintaka.sdsu.edu

J. Horsmeier

unread,
Sep 11, 1991, 10:20:59 AM9/11/91
to

Don't bother, just have a look in `alt.fan.monty-python' (one of my favourites).
It's plagiarism all over the place there ... and no apologies whatsoever 8^)

Jos


|_Jos_Horsmeie...@and.nl_| J.F. Kennedy `Ich bin ein Berliner' |
| O O \O/ O O \O | R. Nixon `I am not a crook' |
|<|> <|/ | <|> \|> |> everybody | R. Reagan `I uhhh ...' |
|/ \ / / \ / \ \ / \ twist! | G. Bush `I don't like broccoli' |
| Zappa for president of the USA | F. Zappa `I am a Hamburger' |

ps with apologies to J.F. Kennedy, R. Nixon, R. Reagan, G. Bush and F. Zappa ;-)

Dana H. Myers

unread,
Sep 11, 1991, 5:01:03 PM9/11/91
to
In article <1991Sep11.0...@crl.dec.com> tre...@crl.dec.com (Win Treese) writes:
>
>Plagiarism being a hot topic in the news these days, I note that at the
>end of the message was the note:
>
> "With apologies to Monty Python"
>
>Should this fail to satisfy the net.community, I shall only provide
>full bibliographic references in extremely detailed footnotes in the
>future.


For the sake of the few who've written me notes:

I'm sorry Win to have accused you of plagarism. The posting
was cute and, as you point out, mentioned Monty Python.

Veteran of the Psychic Wars

unread,
Sep 12, 1991, 4:33:45 PM9/12/91
to
/* <17...@nikhefk.UUCP> by t...@nikhefk.UUCP (Tom Ploegmakers)
*
* When memories, and buffer caches, grew bigger this was no
* guarantee anymore. I heard about a Convex that spend tens of
* seconds syncing after doing lots of installaion work single user.
* Modern unixes, at least bsd's, always sync when you halt them,
* even when they panic. But i still have the old sync, sync, jalt
* on my fingertips.
*

# jalt
jalt: not found
#

:-)

I had a friend at LucasFilm Limited ( he then went to Pixar ) who ended
up one morning doing the following:

# sync
# sync
# sync
# <Control-D>

"Shit," mumbles he under his breath.

*
* tom ploegmakers NIKHEF/K-CSG (t...@nikhefk.nikhef.nl)
*
* po.box 4395, 1009 AJ Amsterdam, the Netherlands.
* phone: -31 20 5922035


--
# grey...@unisoft.com
# "...to raise a signal means to turn the light on; ... Responding to a
# signal means turning the light off (and, under System V, hoping the bulb
# won't blow when it's next turned on)..." -- Dan Bernstein

Anthony A. Datri

unread,
Sep 12, 1991, 11:32:49 PM9/12/91
to
> * When memories, and buffer caches, grew bigger this was no
> * guarantee anymore. I heard about a Convex that spend tens of
> * seconds syncing after doing lots of installaion work single user.

Sure, although perhaps not so much when doing installs as when
moving/restoring filesystems. Sometimes when doing such, I'd notice
that umounting a filesystem took a disconcerting amount of time. Eventually
someone mentioned that a filesystem has to get sync'd before being
unmounted, and then it made sense. I've also found that if you
fire up "update" before mucking around the syncs take much less time 8^)

--

--
"If things fail, read the rest of the release notes."
- x11r5

Ezra Peisach

unread,
Sep 22, 1991, 11:17:27 PM9/22/91
to

You should see a VAX9000 with 512Meg of memory, which comes out to 51meg
of buffers (roughly). I got scared the first time I installed that beast:
Ultrix installation does not run update and apparently doesn't use
sync at all in the process. Personally, I would rather have a sync
between subset loading rather that the scare of a machine hanging on
reboot.

Seth Breidbart

unread,
Sep 24, 1991, 3:56:44 PM9/24/91
to
In article <17...@geovision.gvc.com> p...@geovision.gvc.com writes:
:
>Any body know the reason for zeroing registers twice? I've seen it in the
>few pieces of BAL I've ever tried to understand....

According to my memory, there was some computer that had two copies of
each register in hardware. SUB R1,R1 would subtract one copy from the
other. All instructions that stored into a register would store into
both copies. However, when the machine was powered up, there could be
garbage in the registers, and different garbage in the two copies.
The first zeroing only ensured that the same garbage was in both
copies. The second zeroing actually zeroed the register.

Seth se...@fid.morgan.com

Norman Diamond

unread,
Sep 27, 1991, 1:14:28 AM9/27/91
to

This is pretty hard to believe. SR R1,R1 (if indeed that is the BAL that
was referred to) was very widely used, without repetition. Possibly the
redundant instructions were important in taking up two bytes of space
without changing anything, so that the next instruction would be aligned
on a multiple of 4 (or 8). Usually BCR 0,R0 was used for this purpose,
but I wouldn't be surprised if some programmers used redundant SRs instead.
--
Norman Diamond dia...@jit081.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
signature, n.: acm special interest group on studies of the real world.

0 new messages