4

I'd like to deploy a Python script on a server and have it executed by the cron task scheduler. My script is not a web service or anything of the sort: it reads stuff from a database, does some computations on it and writes the results back to the database.

What would be the best way to deploy such a script? I've been considering either to make a stand-alone deployment using bbfreeze or to install Python on the target machine and install the script inside a virtualenv. What are the pros and cons of each approach? are there any other approaches I should consider?

1
  • does the server not already have python installed? Commented Jul 26, 2015 at 11:33

1 Answer 1

1

I think having the script.py + virtualenv on the server is more convenient:

  • You can use version control to update your program
  • You can edit the script while on the UNIX server (e.g. configs, passwords), test it, then commit back to version control
  • No extra steps of bundling the interpreter with the freeze

In which case you just need a cron line like

@daily cd /path && . venv/bin/activate && script.py
                   ^ the dot is like "source", to activate the virtualenv  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.