Re: Wits end with Python and cron

Discussion in 'Python' started by Fredrik Lundh, Sep 28, 2005.

  1. Justin Delvecchio wrote:

    > I've researched this problem for the last few days. Say I have
    > the following script that I execute from cron on linux. Yes, the
    > following runs quite fine from the command line:


    > And the error I continually get is:
    >
    > Traceback (most recent call last):
    > File "/home/oracle/rods_dbf_file/map_unix.py", line 29, in ?
    > import cx_Oracle
    > ImportError: libclntsh.so.10.1: cannot open shared object file:
    > No such file or directory


    > What is going on? I've googled this thing to death and it seems like I've
    > got two different solutions, PYTHONPATH and LD_LIBRARY_PATH,
    > that should satisfy this. /u01/app/oracle/product/10.1.0/Db_1/lib is where
    > the lib resides.


    have you read the cron documentation? if you had done that, you would
    perhaps have noticed that cron runs jobs with a rather minimal environment.

    if you don't make sure to add the variables required by your program (in
    this case, LD_LIBRARY_PATH), the cron job will fail. (this is true for any
    program run under cron, not just Python programs).

    if you're running a python program directly from cron, you can simply add
    to the environment inside the Python program, before you start importing
    stuff:

    import os # make sure we can load the oracle libraries
    os.environ["LD_LIBRARY_PATH"] = "/u01/app/oracle/..."

    import cx_Oracle

    other approaches include adding a small shell script that sets things up
    properly before running the Python script (and running that shell script
    from cron), and adding environment settings to the crontab file (see the
    cron/crontab documentation for details).

    </F>
    Fredrik Lundh, Sep 28, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Muckey

    At my wits end

    Muckey, Feb 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    353
    Alvin Bruney [MVP]
    Mar 2, 2004
  2. =?Utf-8?B?Q2hyaXM=?=

    at my wits end with CR

    =?Utf-8?B?Q2hyaXM=?=, Mar 21, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    363
    Gordon Smith
    Mar 21, 2005
  3. Chris

    RMI - at my wits end

    Chris, May 15, 2006, in forum: Java
    Replies:
    3
    Views:
    503
    Chris
    May 16, 2006
  4. Calvine Chew

    At wits end! LWP and IIS(?)

    Calvine Chew, May 5, 2004, in forum: Perl Misc
    Replies:
    6
    Views:
    212
    Calvine Chew
    May 7, 2004
  5. Replies:
    10
    Views:
    464
    Tad McClellan
    Oct 6, 2006
Loading...

Share This Page