Topic
  • 3 replies
  • Latest Post - ‏2004-05-18T08:22:35Z by SystemAdmin
SystemAdmin
SystemAdmin
17917 Posts

Pinned topic cron job output

‏2004-05-10T13:16:38Z |
Hello All,

I have a cronjob which runs a script to retrieve a list of records from a table in the database.

When I run this shell script from the command line, then all works fine. I get the output file. But when I run this as a cron job, the output file always comes out as a blank.
I have tried running this as an 'at' job. The output comes out fine.

I have a command to run the db2profile script at the beginning of my file.

I am not sure why the difference in the two methods of running the same shell script. Could any one please thrown some light?
Updated on 2004-05-18T08:22:35Z at 2004-05-18T08:22:35Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    17917 Posts

    Re: cron job output

    ‏2004-05-14T18:38:09Z  
    > I have a command to run the db2profile script at the beginning of my file.

    make sure you do " . ~/sqllib/db2profile" and not actualy run the db2profile
    script.

    please note the "dot" before the db2profile command, also redirect the
    output (stdout and stderr) to a file, something like:

    0 6 * * * /usr/local/mycommand > /tmp/mycommand.out 2>&1

    Regards,

  • SystemAdmin
    SystemAdmin
    17917 Posts

    Re: cron job output

    ‏2004-05-17T00:47:37Z  
    why not try write a separate command file to output the select result and make an invocation in your crontab file
  • SystemAdmin
    SystemAdmin
    17917 Posts

    Re: cron job output

    ‏2004-05-18T08:22:35Z  
    > I have a command to run the db2profile script at the beginning of my file.

    make sure you do " . ~/sqllib/db2profile" and not actualy run the db2profile
    script.

    please note the "dot" before the db2profile command, also redirect the
    output (stdout and stderr) to a file, something like:

    0 6 * * * /usr/local/mycommand > /tmp/mycommand.out 2>&1

    Regards,

    It was the problem with the 'dot'. Missed the subtle point that the db2profile is actually still a script file that needed to be run.

    That sorted the problem. Many thanks.