1

In macOS Terminal.app how can I issue a command similar to caffeinate that keeps all running applications from quitting?

In my System Preferences I have Energy Saver to: computer sleep-never and Display sleep-never, I even have caffeinate issued in the terminal.

After a while of no keyboard or mouse activity the screen will go to login mode. All apps like Excel and Mail have quit except those that required a save.

Even Terminal is asking if I really want to quit. I want all to be as if I were touching my keyboard every few minutes so not even the login screen shows and Excel never quits.

  • What is your exact scenario? Why don't you want your apps to quit, and what's making them do so? – William T Froggard Sep 10 '15 at 15:12
  • 1
    Apps aren't supposed to "quit" normally. In what way are they "quitting"? – DisplayName Sep 10 '15 at 15:24
  • 6
    I could be wrong, but this seems like a classic case of: mywiki.wooledge.org/XyProblem – William T Froggard Sep 10 '15 at 15:41
  • In my system prefs I have energy saver to: computer sleep-never and Display sleep-never, I even have caffeinate issued in the terminal. After a while of no keyboard or mouse activity the screen will go to login mode. All apps like Excel and Mail have quit except those that required a save. Even terminal is asking if I really want to quit. I want all to be as if I were touching my keyboard every few minutes so not even the login screen shows and excel never quits. – Miguel Reznicek Sep 10 '15 at 21:03
  • I have had several Mac Minis running information screens for weeks and months on end, never shutting down or closing apps except during power failures. When the power comes back, the "Start up automatically after a power failure" setting in the Energy Saver System Preferences works as advertized. The root cause of your problem needs to be discovered, not a solution that bypasses what happens. I agree that William T Froggard's XY problem mention is at work here. In Energy Saver, do you have any settings enabled in the Schedule... module? – IconDaemon Nov 3 '16 at 14:48
-1

You can use the screen terminal window manager and its detach feature. This command is installed by default on OS X.

Example scenario.

  • Open a terminal
  • Run screen
  • Run a program of your choice e.g. htop.
  • Suspend this program (Ctrl+z) and run it in background bg
  • Detach your current session (Ctrl+a d)
  • Exit your session and exit the terminal
  • Open the terminal again
  • List running session with screen -ls
  • Go back to your session with screen -r <session id>
  • Use your program again with fg
  • Despite the no comment downvote, this works well. It maybe seems complicated but if you are used to terminal manipulation, it's not. – Ortomala Lokni Nov 3 '16 at 9:28
  • I suspect the down vote was because the answer addresses command line processes and not graphical applications. – Graham Miln Nov 3 '16 at 10:44
  • @Graham Miln But the question says : In macOS Terminal.app how can I issue a command...., there is something I don't understand. – Ortomala Lokni Nov 3 '16 at 13:36
  • The original question has since been extended with comments that talk about the behaviour of Mail.app and Excel.app – both graphical applications. I believe the desire is for something like caffeinate, a command line tool, that will affect macOS graphical applications. screen is a great tool but not quite what this questioner seems to want. – Graham Miln Nov 3 '16 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .