How to keep process running when I lock my Macbook I'm on macOS 10.13.6.

I often need to set a long process running from the terminal, and then lock my Macbook for a while, and I want the process to be still running when the screen is locked. However, the process just hangs as long as the screen is locked. I can confirm that the Macbook is not asleep, and I've checked the box that says "prevent computer from sleeping automatically when the display is off" in "Energy Saver". How do I keep the process running (not hang) when the computer is locked (but not asleep)?
In System Preferences > Energy Saver, check the box for "Prevent computer from sleeping automatically when the display is off" (on laptops, this is under the Power Adapter tab)
In System Preferences > Security &amp; Privacy, check the box for "Require password after sleep or screen saver begins" and set the delay in the dropdown menu to "immediately"


Now, you can hit command-option-power to turn off the display without sleeping the computer, and doing anything that turns on the display (like hitting a key or clicking a mouse button) will prompt you for your account password.



Credits: This answer