Here is the python.
#/usr/bin/env python2.7
import time
from twisted.internet import reactor
from twisted.web.server import Site
from twisted.web.resource import Resource
class ClockPage(Resource):
isLeaf = True
def render_GET(self, request):
return "<html><body>%s</body></html>" % (time.ctime(),)
resource = ClockPage()
factory = Site(resource)
reactor.listenTCP(38123, factory)
reactor.run()
and here is the crontab line,
*/2 * * * * /home/username/webapps/app/main.py
it works from the command line and the */2 is for testing purposes.
Edit:
commandline that works
python2.7 /home/username/webapps/twistedtest/main.py
commandline that doesn't work (with chmod 777 main.py
, again for testing)
/home/username/webapps/twistedtest/main.py
here is the error I get.
import: unable to open X server `' @ import.c/ImportImageCommand/359.
/home/username/webapps/twistedtest/main.py: line 4: from: command not found
/home/username/webapps/twistedtest/main.py: line 5: from: command not found
/home/username/webapps/twistedtest/main.py: line 6: from: command not found
/home/username/webapps/twistedtest/main.py: line 9: syntax error near unexpected token `('
asked
28 Feb '12, 21:58
johnthexiii
1●1●2
accept rate:
0%
literally the dumbest thing I've done in a while. There is no '!' on the first line of the script.