Hey I am running into an issue when trying to run a cron job with a python script from ubuntu. This is what I have done:
1.) Wrote a simple tkinter app: source for the code is from this url - http://www.ittc.ku.edu/~niehaus/classes/448-s04/448-standard/simple_gui_examples/sample.py
#!/usr/bin/python
from Tkinter import *
class App:
def __init__(self,parent):
f = Frame(parent)
f.pack(padx=15,pady=15)
self.entry = Entry(f,text="enter your choice")
self.entry.pack(side= TOP,padx=10,pady=12)
self.button = Button(f, text="print",command=self.print_this)
self.button.pack(side=BOTTOM,padx=10,pady=10)
self.exit = Button(f, text="exit", command=f.quit)
self.exit.pack(side=BOTTOM,padx=10,pady=10)
def print_this(self):
print "this is to be printed"
root = Tk()
root.title('Tkwidgets application')
app = App(root)
root.mainloop()
2.) changed the script to become executable:
chmod 777 sample.py
3.) Added the script to my cronjob to be run every minute for testing purposes. I opened crontab -e and added the following to my file:
* * * * * /home/bbc/workspace/python/tkinter/sample.py
4.) Disclaimer: I did not add any additional environment variables for tkinter nor did I change my cronjob script at /etc/init.d/cron
5.) I was tracking the cron job by doing a tail -f /var/log/syslog
$ tail -f /var/log/syslog
Jul 7 18:33:01 bbc CRON[11346]: (bbc) CMD (/home/bbc/workspace/python/tkinter/sample.py)
Jul 7 18:33:01 bbc CRON[11343]: (CRON) error (grandchild #11344 failed with exit status 1)
Jul 7 18:33:01 bbc CRON[11343]: (CRON) info (No MTA installed, discarding output)
Jul 7 18:33:01 bbc CRON[11342]: (CRON) error (grandchild #11346 failed with exit status 1)
Jul 7 18:33:01 bbc CRON[11342]: (CRON) info (No MTA installed, discarding output)
Any help on debugging this issue will be most appreciated...