The Mishnah Berura (סימן תקפ”א ס”ק ב’) says there is a minhag to recite- לדוד ה’ אורי וישעי מזמור כ”ז during Chodesh Elul through Yom Hakippurim. Another minhag is to say it through Shimini Atzeres. The main source for this minhag is according to the Midrash that “אורי” – זה ראש השנה, “וישעי” זה יום הכיפורים. The Sifrei Kabalah speak about how saying this קפיטאל is מבטל גזירות רעות.
There are various minhagim when it is said. The Mishna Berurah says בקר וערב. The מטה אפרים says the minhag is to say it after Mincha. The אלף המגן says that many have the minhag to say it after Maariv. The meforshim explain that really there is no machlokes, and everyone agrees it should be said “בערב” – towards nighttime. In the countries that davened Mincha earlier in the day, they said it when davening Maariv. In the places that davened Mincha very close to shkia and in some places even afterwards, they said it by Mincha since it was already evening. Today, minhag Ashkenaz is to say it by maariv, and the minhag of nusach Sefard is to say it by Mincha.
There are different opinions regarding what one should do if he is davening in a minyan that has a different minhag from what he does. Reb Shlomo Zalman zt”l says that one should do like the tzibbur. Therefore if one has the minhag to say it by Mincha and the minyan that he davens at says it by Maariv, then he should only say it by Maariv. This is the opinion of R’ Chaim Kanievsky shlit”a. If one already said it by Mincha and he is now davening in a minyan that says it by Maariv, R’ Elyashiv zt”l rules that he does not have to say it again. According to Reb Shlomo Zalman, he should say again with the tzibbur.
If one has the minhag to say it by Mincha and he forgot to say it, there is a machlokes what to do. Some say he should say it by Maariv. Others say that since his minhag is to only say it by Mincha, he can’t say it by Maariv because of the prohibition to say pessukim at night.
There is another machlokes what one should do if he finished Shmone Esrei after the tzibbur has already ended Aleinu. Reb Nissim Karelitz zt”l says that he should say לדוד before עלינו in order to say it together with the tzibbur. Reb Chaim Kanievsky shlit”a holds he should say עלינו first in the regular order of davening.
Many don’t have the minhag to recite it at all. The ספר מעשה רב says that the גר”א did not say it. This was also the הנהגת המהרש”א. Some say the reason for not saying it is because of טירחא דציבורא. Many do not say on Shabbos, which is the minhag of Sharei Chesed. This is also the minhag in Yeshivas Telshe. They also only say it by shachris and don’t say it on Rosh Hashana, Yom Hakippurim, or after Yom Hakippurim like the first minhag mentioned in the Mishnah Berura. Others have the minhag not to say it Friday night so everyone can go home right away and make Kiddush. This is the minhag of Kehillas Perushim.
Prepared by R’ Avrohom Yehoshua Ziskind
_________________________
1Sources:ספר האלולים קדוש לה’,דרשו