WebFaction
Community site: login faq

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
112
accept rate: 0%

edited 29 Feb '12, 16:59

1

literally the dumbest thing I've done in a while. There is no '!' on the first line of the script.

(28 Feb '12, 22:16) johnthexiii

Per the comments, the first line of the script was missing the "!" :)

permanent link

answered 29 Feb '12, 09:30

seanf
12.2k41836
accept rate: 37%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×337
×81
×50

question asked: 28 Feb '12, 21:58

question was seen: 6,034 times

last updated: 29 Feb '12, 16:59

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM