MacOS - Running a script at Startup
Steps to execute a script on startup:
- Create the Shell Script:
- Create a file named start_jekyll.sh in your Jekyll site directory:
1
nano /Users/Sakharam.Shinde/github/sakharams.github.io/start_jekyll.sh
Add the following content:
1 2 3
#!/bin/bash cd /Users/Sakharam.Shinde/github/sakharams.github.io /usr/local/bin/bundle exec jekyll serve --watch > /tmp/jekyll-serve.log 2>&1
Make the script executable:
1
chmod +x /Users/Sakharam.Shinde/github/sakharams.github.io/start_jekyll.sh
- Create a the Plist File
~/Library/LaunchAgents/com.user.jekyllserve.plist
:- Update the plist file to call the shell script:
```xml <?xml version=”1.0” encoding=”UTF-8”?> <!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
Load the Launch Agent:
1
launchctl load ~/Library/LaunchAgents/com.user.jekyllserve.plist
- Verify and Check Logs:
1
launchctl list | grep com.user.jekyllserve
Check the log file:
1
tail -f /tmp/jekyll-serve.log
To unload the agent
1
launchctl unload ~/Library/LaunchAgents/com.user.jekyllserve.plist
This post is licensed under CC BY 4.0 by the author.