0
import requests  
import json  
import Credential  
import psycopg2   
from sqlalchemy import     

I am using “sqlalchemy” library as shown above to stored value into the database. The program running successfully when i run from command prompt eg. "python filename.py". But i need to run program after specific interval of time. So, I created the shell file and set the cronjob to run the shell file for specific time as below:

15 16 22 7 * /home/ubuntu/Clio-Python/new_clio_shell.sh

But the cron not getting sqlalchemy library. So how should I import this library in the crontab? Should I need to import path in the cron file? If yes how to do that?

shivsn
  • 7,680
  • 1
  • 26
  • 33

1 Answers1

0

Importing path the cron file should work, but you can go one further and import your whole environment.

Add this to your cron:

30 08 * * * env > ~/cronenv After it runs, do this:

env - cat ~/cronenv /bin/sh This assumes that your cron runs sh. I believe this is the default.

Original solution by mmccoo can be found here.

Community
  • 1
  • 1
fyodrpetrovich
  • 135
  • 1
  • 7