Deploying Python script on Unix server

I would like to deploy a Python script to a server and execute it using the cron task scheduler. My script is not a web service or anything like that: it reads stuff from the database, does some calculations, and writes the results back to the database.

What would be the best way to deploy a script like this? I was considering either a standalone deployment using bbfreeze, or installing Python on the target machine and installing the script inside the virtual one. What are the pros and cons of each approach? are there any other approaches i should consider?

+3


source to share


1 answer


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

  • You can use version control to update your program.
  • You can edit the script on the UNIX server (like configs, passwords), test it and then revert back to version control
  • No extra steps to bind the interpreter to freeze


In this case you only need the cron line like

@daily cd /path && . venv/bin/activate && script.py
                   ^ the dot is like "source", to activate the virtualenv  

      

0


source







All Articles