My script only runs after logging into the user FooUser. I would like to bash file to run before login. I am not sure why it only runs after user login.

The plist and path for boot-script.plist:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
<plist version="1.0">




The bash script and path for boot.sh:



function startup(){

    cd /Users/FooUser/Desktop
    touch FooFile


I believe this is the proper setup for startup processes, having the plist stored in the LaunchAgents

  • launchctl load -w boot-script.plist

  • boot-script.plist owner is root and group is wheel

  • boot.sh permission set to executable


You can't run a script before log-in, but you can call it as part of the log-in process.

The usual place to do this is in ~/.bashrc: you will need to look at what's in it already and decide on the appropriate place in the log-in sequence.

You will also need to decide if you want to call it in a subshell, which will perform the touch but leave the calling shell unchanged:


or whether to call it in the log-in shell itself, which will set the current directory to /Users/FooUser/Desktop and make the startup function available after log-in:

. boot.sh
  • That seems to make more sense. With OS X design it doesn't seem to be necessary to run processes before login. – localplutonium Jun 21 '18 at 23:43
  • I don't really understand how Plists are used (I'm a Linux user), but it looks as though the Plist itself invokes the boot.sh script when the application starts, without the need to call it in the shell start-up. – AFH Jun 21 '18 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.