Positive commandment · Mitzvat Aseh #36 of 613
That the priests and the Levites work in the Temple in shifts
להיות הכהנים עובדין במקדש משמרות משמרות, ובמועדים עובדין כאחד
The verse · Devarim 18:6
וְכִי־יָבֹא הַלֵּוִי מֵאַחַד שְׁעָרֶיךָ מִכׇּל־יִשְׂרָאֵל אֲשֶׁר־הוּא גָּר שָׁם וּבָא בְּכׇל־אַוַּת נַפְשׁוֹ אֶל־הַמָּקוֹם אֲשֶׁר־יִבְחַר ה׳
“And if a Levite come from any of thy gates out of all Yisra᾽el, where he sojourned, and come in all eagerness to the place which the Lord shall choose;”
The Rambam’s words
For the priests to serve in the sanctuary in individual watches; and for them to all serve as one on the festivals, as [Deuteronomy 18:6-8] states: "When the Levite shall come... [he can serve]...with the exception of that which is theirs by ancestral right."
להיות הכהנים עובדין במקדש משמרות משמרות, ובמועדים עובדין כאחד, שנאמר: "וְכִי יָבוֹא הַלֵּוִי..." (דברים יח, ו) "לְבַד מִמְכָּרָיו עַל הָאָבוֹת" (שם, ח).
Why · Sefer HaChinuch #509
That the priests and the Levites work in the Temple in shifts
“It is from the roots of the commandment of known and set shifts [that it is] because all work that is incumbent upon a number of [assigned] men will be done properly, and no laziness or despondency or impatience is found in it.”
Who & when
“And this commandment is practiced by the males of the priesthood and the Levites at the time of the [Temple].”
Where in the Mishneh Torah
Hilchot Vessels of the Sanctuary and Those Who Serve Therein הלכות כלי המקדש והעובדין בו