There are various ways to prevent your Mac from sleeping and keep it awake for longer.
Adjusting the Energy Saver settings is one method to prevent sleep. For macOS Ventura and later, go to System Settings → Displays → Advanced and enable 'Prevent automatic sleeping when the display is off'. For macOS Monterey and earlier, go to System Preferences → Energy Saver and adjust the 'Turn display off after slider' to 'Never'. This method is useful when the Mac is plugged in.
Using the Terminal command 'caffeinate' is another option to temporarily prevent sleep. Open Terminal and type 'caffeinate -d' to keep the Mac awake until the Terminal window is closed. Additional options like 'caffeinate -t 3600' can be used to keep the Mac awake for a specified time.
Third-party apps, such as Mouse Jiggler, provide the ability to simulate cursor movement to prevent sleep. This is useful for applications that require actual cursor movement to detect activity, like remote desktops, web applications, security portals, live monitoring dashboards, and software testing. Mouse Jiggler also includes Silent Mode to move the cursor invisibly and customizable deactivation options.