I am trying to run a python script to run on startup. I have the following file: com.test.service.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.test.service</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>/var/www/html/app/appstart.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
copied to ~ / Library / LaunchAgents /
loaded as
launchctl load -w ~/Library/LaunchAgents/com.test.service.plist
The script has two lines:
/usr/bin/python /var/www/html/app/app.py
echo "hello" >> /var/www/html/app/test.txt
the script is launched (the test.txt file is created using 'hello' in it) however, app.py does not start. for testing purposes, all i did in app.py was:
import os
os.system("echo 'python' >> /var/www/html/app/test.txt")
if i just ran appstart.sh in the terminal then python doesn't run any problems
I have already followed the instructions in this question , but no luck
source
share