MacOS – |OSX 10.10.5] Script execution stops when screen locked

macosscreen-lockscriptterminal

I was running a script that takes ages in Terminal.

I wanted to run it unsupervised while I was working away from my MacBook, so I chose from the menu (top right) username > Login Window…, which is NOT logout, but the lock screen.

I was expecting the script to run. When I returned hours later and unlocked the screen (by typing in my password), I had to find out that while the screen was locked the script was paused all the time, and just continued where it set off when I unlocked the screen.

The expected behaviour (known from other UNIX derivatives) would have been to run while the UI was locked and secure.

How can I achieve this?

Best Answer

You are right that Fast User Switching (activated by clicking UsernameLogin Window… does not log you out. However it does suspend actively running applications, thus preventing intensive tasks (or even media playback) from interfering with another user’s use of your system.

What you want to do instead is lock your screen using Keychain Access.

Press ⌘ cmd space, followed by Keychain Access to launch the app. Then from the menu bar, click Keychain AccessPreferencesGeneral and check Show keychain status in menu bar.

A padlock icon will appear in the system area of your menu bar. Just click Lock Screen to lock your screen.

Lock Screen

As per @M.J.K, you may also need to prevent your Mac from going to sleep before walking away.