Launch shell script on login in Mac OS (OS X)

前端 未结 3 1043
独厮守ぢ
独厮守ぢ 2020-12-08 11:07

I have this shell script Test.sh:

#! /bin/bash

FILE_TO_CHECK=\"/Users/test/start.txt\"
EXIT=0

while [ $EXIT -eq 0 ]; do
    if [ -f \"$FILE_TO         


        
3条回答
  •  旧时难觅i
    2020-12-08 12:12

    You can't just place plain scripts in that folder. You need a "specialized bundle" how Apple calls it, basically a folder with your executable, and a .plist configuration. And you should put it in /Library/StartupItems since /System/Library/StartupItems/ is reserved for the operating system. Read all about it here:

    https://developer.apple.com/library/mac/documentation/macosx/conceptual/bpsystemstartup/chapters/StartupItems.html

    Also note that the whole stuff is marked as deprecated technology. And that Apple is suggesting the use of launchd. There is an example how to set it up here:

    https://superuser.com/questions/229773/run-command-on-startup-login-mac-os-x

提交回复
热议问题