From The Jewish Holidays by Michael Strassfeld, p. 73-74
Tikkun Leil Shavuot
A kabbalistic custom emanating from the mystics in Safed (sixteenth century) is to stay up the whole (first) night of Shavuot studying Torah. The tikkun -- a set order of study -- was composed of selections from the Bible, rabbinic literature and even mystical literature such as the Zohar. In this fashion the kabbalists prepared for the momentous revelation of the following morning.
This practice of staying up all night is in stark contrast to that of the Israelites at Sinai, who according to tradition slept late into that morning and had to be awakened by Moses. In atonement for this, Jews nowadays stay awake all night. The sense of preparation for Sinai is heightened by a mystical tradition holding that the skies open up during this night for a brief instant. At that very moment, we are told, God will favorably answer any prayer. The kabbalists also regard Shavuot as the wedding of God and Israel and of God's masculine and feminine parts. Therefore, we stay up all night to "decorate the bride." While the kabbalists instituted other tikkunim (for the seventh day of Pesah and for Hoshana Rabbah), this is the only one widely observed.
The traditional tikkun includes the study of small sections from each book of the Torah and Talmud, symbolically representing all of the central texts of Judaism.
A lesser-known custom is to recite the whole book of Psalms by staying up late the second night of Shavuot. This is because of the tradition the King David, the author of the Book of Psalms, was born and died on Shavuot. Another custom is to read the Book of Psalms during the afternoon of the second day of Shavuot.
At sunrise, the tikkun is ended and the morning services are recited. One custom is to ritually immerse yourself in the morning of Shavuot in remembrance of the three days of preparation observed by the Israelites in the desert. Purifying your body is a wonderful way to prepare to receive the Torah on the morning of Shavuot.
From The Sign by S.Y. Agnon from A City in its Fullness
Now children, listen to me: I'll tell you something of my youth. Now your father is old, and if he let his beard grow as did Abraham, you'd see white hair in his beard. But I too was once a little boy who used to do the things children do. While the old men sat in the house of study preparing themselves for the time of the giving of the Torah the following morning, my friends and I would stand outside looking upward, hoping to catch the moment when the sky splits open and everything you ask for (even supernatural things!) is immediately given you by God -- if you are worthy and you catch the right moment. In that case, why do I feel as though none of my wishes has ever been granted? Because I had so many things to ask for that before I decided what to wish first, sleep came upon me and I dozed off. When a man is young, his wishes are many; before he gets around to asking for anything, he is overcome by sleep. When a man is old, he has no desires if he asks for anything he asks for a little sleep.
(יא) וְהָי֥וּ נְכֹנִ֖ים לַיּ֣וֹם הַשְּׁלִישִׁ֑י כִּ֣י ׀ בַּיּ֣וֹם הַשְּׁלִישִׁ֗י יֵרֵ֧ד יְהוָ֛ה לְעֵינֵ֥י כָל־הָעָ֖ם עַל־הַ֥ר סִינָֽי׃
(11) and be ready against the third day; for the third day the LORD will come down in the sight of all the people upon mount Sinai.
(יא) והיו נכנים. אולי לא יישן אדם בהם בלילה. שישמעו קול ה' בבקר. כדרך כהן גדול ביום הכפורים
(11) Be Ready: Perhaps a person shouldn't sleep on them at night, because they will hear the voice of God in the morning, like the way of the Kohen Gadol on Yom Kippur.
ר' חנינא אומ' בחדש השלישי היום כפול בלילה וישנו ישראל עד שתי שעות ביום ששינת יום העצרת עריבה והלילה קצרה ויצא משה ובא למחנה ישראל והיה מעורר ישראל משינתם ואמ' להם עימדו משינתכם שהרי אלהיכם מבקש ליתן לכם את הא"רץ התורה כבר החתן מבקש להביא את הכלה להכניס לחופה כדי ליתן לכם את התורה באה השעה שנ' ויוצא משה את העם וכו' ואף הב"ה יצא לקראתן כחתן היוצא לקראת כלה כן הב"ה יצא לקראתן ליתן להם את התורה שנ' ה' בצאתך משעיר וכו'
Rabbi Chanina said : In the third month the length of daytime is double the length of nighttime, and the Israelites slept until two hours of the day, for sleep on the day of the (feast of) Atzeret (Shavuot) is pleasant, the night being short. And Moses went forth and came to the camp of the Israelites, and he aroused the Israelites from their sleep, saying to them: Arise ye from your sleep, for behold, your God desires to give the Torah to you. Already the bridegroom wishes to lead the bride and to enter the bridal chamber. The hour has come for giving you the Torah, as it is said, "And Moses brought forth the people out of the camp to meet God " (Ex. 19:17). And the Holy One, blessed be He, also went forth to meet them; like a bridegroom who goes forth to meet the bride, so the Holy One, blessed be He, went forth to meet them to give them the Torah, as it is said, "O God, when thou wentest forth before thy people" (Ps. 68:7).
(62) At midnight I will rise to give thanks to You because of Your righteous ordinances.
ודוד בפלגא דליליא הוה קאי מאורתא הוה קאי דכתיב (תהלים קיט)קדמתי בנשף ואשועה וממאי דהאי נשף אורתא הוא דכתיב (משלי ז)בנשף בערב יום באישון לילה ואפילה אמר רב אושעיא אמר רבי אחא הכי קאמר (דוד) מעולם לא עבר עלי חצות לילה בשינה. רבי זירא אמר עד חצות לילה היה מתנמנם כסוס מכאן ואילך היה מתגבר כארי רב אשי אמר עד חצות לילה היה עוסק בדברי תורה מכאן ואילך בשירות ותשבחות. ונשף אורתא הוא הא נשף צפרא הוא דכתיב (שמואל א ל)ויכם דוד מהנשף ועד הערב למחרתם מאי לאו מצפרא ועד ליליא לא מאורתא ועד אורתא אי הכי לכתוב מהנשף ועד הנשף או מהערב ועד הערב אלא אמר רבא תרי נשפי הוו נשף ליליא ואתי יממא נשף יממא ואתי ליליא. ודוד מי הוה ידע פלגא דליליא אימת השתא משה רבינו לא הוה ידע דכתיב (שמות יא) כחצות הלילה אני יוצא בתוך מצרים מאי כחצות אילימא דאמר ליה קודשא בריך הוא כחצות מי איכא ספיקא קמי שמיא אלא דאמר ליה (למחר) בחצות (כי השתא) ואתא איהו ואמר כחצות אלמא מספקא ליה ודוד הוה ידע דוד סימנא הוה ליה דאמר רב אחא בר ביזנא אמר רבי שמעון חסידא כנור היה תלוי למעלה ממטתו של דוד וכיון שהגיע חצות לילה בא רוח צפונית ונושבת בו ומנגן מאליו מיד היה עומד ועוסק בתורה עד שעלה עמוד השחר
How David rose at midnight! He rose at eventide ; as it is written, "I arose early beneshef and cried" (Ps. 119:147). Whence is it learnt that neshef means evening ? Because it is written, "In the twilight [beneshef], in the evening of the day, in the blackness of night and the darkness" (Prov. 7:9). R. Osha'ya said in the name of R. Aha : Thus declared David, "Midnight never passed me by in my sleep." R. Zera said : Until midnight David used to slumber like a horse, but from thence he grew strong like a lion. Rab Ashe said: Until midnight he was occupied with words of Torah, but from thence with psalms and praises. Neshef means evening! Lo, it means the morning ; for it is written, "And David smote them from the neshef even unto the evening ['ereb] of the next day" (I Sam. 30:17). Is this not to be understood to mean from the morning unto the evening? No, from evening unto evening. If so, the text should have read "from the neshef unto the neshef" or "from the 'ereb unto the 'ereb"! But, says Raba, there are two occasions in the day called neshef; there is the neshef of the night followed by day, and the neshef of the day followed by night. Did David know when it was [exactly] midnight, since even Moses our teacher was not certain ; as it is written, "About midnight will I go out into the midst of Egypt" (Exod. 6:4)? What means "about midnight"? Are we to suppose that the Holy One, blessed be He, used the phrase "about midnight" to Moses? Can there be any doubt in the mind of God? Nay; God told him "At midnight"; but Moses came and said "about midnight." Hence it is to be understood that Moses was in doubt, but David did know it! He had a sign. For R. Hannah b. Bizna said in the name of R. Simeon Hasida: There was a harp hanging above David's bed, and when the time of midnight arrived a North wind came and blew upon it, so that it produced melody. He used immediately to rise and occupy himself with Torah until the break of dawn.
R. Yehudah said, There are two firmaments, as it is said, (Deuteronomy 10:14) "Behold, unto the Lord your God belong the heaven and the heaven of heavens." Resh Lakish said, There are seven, and these are them: Vilon, Rakia, Sh'chakim, Z'vul, Ma'on, Machon, Aravot. Vilon has no purpose at all except for the entering of morning the leaving of evening, and renewing every day the work of Creation, as it is said, (Isaiah 40:22) "That stretches out the heavens as a curtain, and spreads them out as a tent to dwell in." Rakia, within it are set the sun and moon, stars and constellations, as it is said, (Genesis 1:17) "And God set them in the Rakia of the heaven." Sh'chakim, within it stand the millstones and grind manna for the righteous, as it is said, (Psalms 78:23) "And he commanded the Sh'chakim above and opened the doors of heaven; and he rained down manna upon them to eat..." Z'vul, within it is [the heavenly] Jerusalem and the Temple, and the built altar, and Michael the High Officer stands and offers upon it an offering, as it is said, (I Kings 8:13) "I have surely built a house of Z'vul, an institute for You to dwell in forever." And where is it called heaven? As it is written, (Isaiah 63:15) "Look down from heaven and behold from Z'vul your holiness and your glory." Ma'on, within it are the classes of the ministering angels, who utter His song at night and are silent in the day for the honor of Israel, as it is said, (Psalms 42:9) "By day the Lord commands His kindness, and by night His song is with me." Resh Lakish said, Anyone who delves into Torah by night, the Holy One, blessed be He, extends over him the thread of kindness by day, as it is said, (Psalms 42:9) "By day the Lord commands His kindness." And what is the reason that "By day the Lord commands His kindness"? Because "by night His song is with me." And some say, Resh Lakish said, Anyone who delves into Torah in this world, which is likened to the night, the Holy One, blessed be He, extends over him the thread of kindness for the world to come, which is likened to the day, as it is said, (Psalms 42:9) "By day the Lord gives his merciful command, and by night his song is with me."