I have a Python program that writes to the /etc/hosts file. It works correctly manually entered using the sudo command. I want it to open automatically. I can load it into sudo launchctl but it returns PID - Status 1.

How do I fix this?

  • Please add a link to the python app/script/py file!
    – klanomath
    Commented Mar 17, 2017 at 19:32

1 Answer 1


PID - Status 1 means that the process doesn't have enough privileges to access some files (presumably /etc/hosts). To be able to execute script as root, you need to move the loader to /Library/LaunchDaemons or /System/Library/LaunchDaemons

(processes in /Library/LaunchAgents/ or ~/Library/LaunchAgents/ are run as current user so they don't have root rights).

You must log in to answer this question.

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