Python virtualenv and crontab

I created a small simple bot in python to download the updated GeoNames daily updated files to be processed by the database.  These files are generated each day and remove the need to load a full 2GB dataset into the database to keep the database updated.

The python application I wrote utilized virtualenv so to ensure that the correct python version with the correct environmental settings was ran I needed to do a little extra

This process runs under my user on my home server so I added this line to my user’s crontab

the command that was added was

This command will run every day at noon, local time

Change directory into the solution directory created

the && this is used by the shell to run the following command ONLY if the proceeding one is successful.  So if for some reason the ‘cd’ command fails there will be no attept to run the python command.

 This will execute the script using the virtualenv’s version of python.  This is the relative path for the virtualenv python command to my project directory.

The ending redirect redirects the output of both the stderr and stdout to the /dev/null sink.


Got a lot of help from this thread:


Author: Axe
I am a senior developer. Ride my motorcycle whenever I can. Love photography, hiking, camping, cooking, coding, and cheese cake!

Leave a Reply