I write the following program to run my program as a daemon but it is not getting run; when i run the program from python debugger it works.
I am using Mac os x.
/User/Library/LaunchDaemons/com.bobbob.osx.test.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.bobbob.osx.test</string>
<key>Program</key>
<string>/Users/vivekbhintade/Desktop/test.py</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
/Users/vivekbhintade/Desktop/test.py:
import urllib2
from datetime import datetime
import smtplib
from smtplib import SMTPException
import threading
def checkerror():
#my code which works fine individually, which sends mail after 5 seconds to recipients.
checkerror()
And also i run the program from terminal with following command.
launchctl load /Library/LaunchDaemons/com.bobbob.osx.test.plist
This does not result in any errors.
launchctl load /Library/LaunchDaemons/com.bobbob.osx.test.plistwork?launchctlalso send the email you expect? How do you run it from the terminal? With$ python test.py? It seems to me that#!/bin/env pythonis missing at the beginning of your file, so the os doesn't know how to run it.