I have some python scripts saved in a sub-folder called "Documents/downloadFundamentals"

And I have the following bash script:

/home/john/.virtualenvs/investFundamentals/bin/python scrapStockList.py
/home/john/.virtualenvs/investFundamentals/bin/python downloadHistoricalData.py
/home/john/.virtualenvs/investFundamentals/bin/python updateHistoricalData.py
/home/john/.virtualenvs/investFundamentals/bin/python insertDocsToCollection.py
/home/john/.virtualenvs/investFundamentals/bin/python filterStocks.py
/home/john/.virtualenvs/investFundamentals/bin/python getCurrentPortfolio.py
/home/john/.virtualenvs/investFundamentals/bin/python accountSummary.py

The crontab task seems to be running, but no output.

Do I need to add the directory before each.py?


Short answer - yes, you have to make it either

/home/john/.virtualenvs/investFundamentals/bin/python /path/to/script/scrapStockList.py

or use #!/usr/bin/env python and make each file executable with chmod +x /path/to/scrapStockList.py. Use of virtualenv suggests you may be running Python version other than system default, so probably first option is more suitable for your case.

To quote related post by Gilles:

Cron's default path is implementation-dependent, so check your man page

When you call python script.py, the interpreter looks for script.py in current working directory. So your commands fail because Python interpreter in your question starts out in the working directory which is other than where your scripts are located.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.