If you have long-running tasks you surely want to keep your Mac awake to at allow them to complete, or more. A lot of GUI applications claimed to fit the bill but the first one I tried let the Mac go to sleep! The solution is caffeinate; run it from the terminal.
Here is the flag for preventing the machine from sleeping, perhaps the most important one:
-s Create an assertion to prevent the system from sleeping. This asser- tion is valid only when system is running on AC power.