How to set virtualenv for a crontab?

Recent I was asked  to batch run Python script in a virtualenv and also run in crontab.

for example,  pyspark_hello_world.py


I want to run it in bash, after some research , I got a solution,

name it “runpy”, now I can easily run it in bash

or use it in crontab

btw, if under Windows,

we can add the following code at the top of pyspark_hello_world.py

and runpy.bat is like this,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.