Prevent your Mac from entering sleep mode. Specify sleep and wake settings.
Check out these Sleep Control Apps:
Stim
Stim prevents your Mac from going to sleep or keeps its screen from dimming. It can also keep your Mac awake only when running a specific program.
Sleepr
This simple menu bar app brings back the option to set a timer at the end of which your Mac goes into sleep mode (removed from macOS Ventura and Sonoma).
Insomniaz
This menu bar app prevents your Mac from falling asleep at all costs. It allows you to use “clam-shell” mode without hooking up a power source.
Don’t go to sleep
This menu bar app prevents your Mac from sleeping while selected applications are running.