Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2007
    Posts
    38

    Unanswered: Getting error while scheduling a script thru cron

    Hi all,

    I am trying to schedule a script thru cron and i am getting the error

    produced the following output:
    /export/home/db2inst1/utility/reorg.sh: ~db2inst1/sqllib/db2profile: not found

    When I execute the script individually its working perfect, but when thru cron its giving me error

    There are already 4 scripts scheduled thru cron and they are working perfect,
    but when I added the new one to the list its erroring me out only for this script.

    Can someone help me please, thank u all in advance.

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Your .profile is not executed when running cron jobs
    You must set your environment in your script
    e.g.
    . .profile # a space between the . and .

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Could you show us the content of your reorg.sh script?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    Nov 2007
    Posts
    38
    But there are other scripts scheduled thru cron and they are working fine.

  5. #5
    Join Date
    Nov 2007
    Posts
    38
    Stolze the script is like this. As I said it works fine when I execute it alone.

    #!/bin/ksh
    . ~db2inst1/sqllib/db2profile

    DIR=/export/home/db2inst1/utility
    DATE='date'

    db2 "connect to capprddb";

    db2 "select substr('reorg table '||rtrim(t.tabschema)||'.'||t.tabname||' index '||rtrim(indschema)||'.'||indname||' use tempspace1;'
    ,1,125) from syscat.indexes i, syscat.tables t where i.tabname =t.tabname and t.type ='T' and (indextype='CLUS' or uniquerule='U' o
    r uniquerule='P') order by t.tabschema, t.tabname" > $DIR/reorg.out;

    sed -e '1,2d' $DIR/reorg.out > $DIR/reorg.log;

    rm $DIR/reorg.out

    db2 -tvf $DIR/reorg.log > $DIR/reorg_report.txt

    cat $DIR/reorg_report.txt | mailx -s "Reorg Cap One UAT" xxx@xxx.com

    db2 connect reset;


    Thank you all

  6. #6
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Do the other scripts also source the db2profile? If they do, you have probably some sort of strange character in your script (what does a hexdump show?).

    You can also try replacing "~db2inst1" with "/export/home/db2inst1". Since you hardcode the directory a couple lines below anyway, I don't see any point in trying to be more flexible in the 2nd line.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  7. #7
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Do the other scripts also source the db2profile? If they do, you have probably some sort of strange character in your script (what does a hexdump show?).

    You can also try replacing "~db2inst1" with "/export/home/db2inst1". Since you hardcode the directory a couple lines below anyway, I don't see any point in trying to be more flexible in the 2nd line.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  8. #8
    Join Date
    Nov 2007
    Posts
    38
    Hi Knut, as you said I tried using "/export/home/db2inst1" instead of "~db2inst1" and it worked... Thank you very much.

    But how come its working for other scripts using the source db2profile. Any specific reason? And also when you asked me "what does a hexdump show". Where can I find that?

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •