WebFaction
Community site: login faq

Hi,

I have created a small python script (thread) that inserts random values to my database (postgresql). I want to have it running in the background while users interact with my web site (in django).

  1. Am I allowed to do this?
  2. If yes, how am I supposed to do this? How can I restart it if it is running? (e.g. when I want to modify the file and start again)

asked 06 May '11, 07:39

xpanta
622844
accept rate: 0%


  1. Yes, you are allowed to do this as long as your script behaves nicely - i.e. it is not using too much CPU time. Make sure to add some sleep interval between the different iterations in the script
  2. Since you have written the script, you should have no problems running it. As for terminating it - you can simply kill the process that corresponds to the script (you can see your processes with 'ps -u your_username -F')
permanent link

answered 06 May '11, 08:06

tie
1.4k13
accept rate: 44%

Thanks.

My script runs once a day for not more than 2 seconds.

My question is where to add the script in order to be run automatically (something like in bash.rc).

Or how to start the script and let it run in the background. I am not into unix so much.

Any help would be appreciated

(06 May '11, 08:26) xpanta

If you need to run your script periodically, you can set it up as a cron job. See this article on the subject:

http://docs.webfaction.com/software/general.html#scheduling-tasks-with-cron

(06 May '11, 08:33) tie
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
×25

question asked: 06 May '11, 07:39

question was seen: 4,910 times

last updated: 06 May '11, 08:33

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