How to Safely Force Shutdown of Mac

后端 未结 6 1324
旧时难觅i
旧时难觅i 2020-12-19 10:07

What I want

I\'m developing a little app to force me to only work at certain times of day - I need something to force me to stop working in the even

相关标签:
6条回答
  • 2020-12-19 10:33

    Forcing your computer to shut down (and discard any unsaved work) doesn't sound like a good idea to me. Wouldn't it be easier and safer to just set an alarm clock to remind yourself when you should stop working, and walk away from your computer when it rings? (That's what I do.)

    Edit: That might have come across as a bit rude, which was not my intention at all. (I had no intention of making fun of your question or anything like that.) I just think that this would be a better solution to this problem :)

    0 讨论(0)
  • 2020-12-19 10:40

    The shutdown command sends running processes a signal to terminate, giving them a chance to do clean up work, if needed. So generally, when an application receives this signal (SIGTERM(inate)) it should wrap up and exit.

    IIRC in Snow Leopard (10.6) Apple added something called fast-shutdown (or similar) which will send processes that have been flagged as being ok with it a SIGKILL signal, shutting them down without chance for cleanup work. This is supposed to make shutdown faster. The default is that applications still get SIGTERM and have to opt-in for SIGKILL; and they can mark themselves as "dirty", i. e. having unsaved work and do not want to be killed forcibly.

    So while shutting down in the middle of a disk utility run will abort whatever disk utility is doing, IMHO it would not cause data corruption in general. However depending on the operation you are currently running, you could end up with an incomplete disk image or a half-formatted partition. Maybe you want to refrain from using it when you know the end of your configured work time is coming close.

    Using cron to schedule the shutdown is a viable option if you want it to happen at a specified time. If you want it to happen after a certain amount of time after you log in, you could use the number parameter to shutdown to specify say 8 hours from now.

    0 讨论(0)
  • 2020-12-19 10:41

    Maybe cron is installed on your computer? It's wonderful =)

    0 讨论(0)
  • 2020-12-19 10:47

    Use AppleScript to tell application "System Events" to shut down.

    0 讨论(0)
  • 2020-12-19 10:57

    If you want to lose unsaved work then shutdown -h is your only answer.

    However, anyone who has debugged a full-screen app on OS X knows that is it very easy (some say too easy) for an app to capture the screen and render the computer essentially useless (without SSHing from another computer to kill the process.) That's another alternative.

    0 讨论(0)
  • 2020-12-19 10:58

    the recommended way to schedule a shutdown of your computer on a regular basis is in the system preferences -> Energy Saver panel. Click on the "schedule" button in the lower right hand corner. the rest is self explanatory...

    0 讨论(0)
提交回复
热议问题