It is worth looking at Ola Hallengren's index maintenance routines at http://ola.hallengren.com/.
This checks statistics so that only those indexes that need rebuilding get processed. This can cut down the maintenance window needed for index rebuild.
Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.
When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara