xargs and gzip (crontab, ksh and sh) - HP UX

This is a discussion on xargs and gzip (crontab, ksh and sh) - HP UX ; Hello, I am using: HP-UX comp B.11.00 U 9000/800 667349342 unlimited-user license I have a problem with gzip. In crontab I have a script that has a line: find /path/to/directory/ -name "*".name_of_files | xargs gzip >> $LOGFILE 2>&1 This however ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: xargs and gzip (crontab, ksh and sh)

  1. xargs and gzip (crontab, ksh and sh)

    Hello,

    I am using:
    HP-UX comp B.11.00 U 9000/800 667349342 unlimited-user license


    I have a problem with gzip. In crontab I have a script that has a
    line:

    find /path/to/directory/ -name "*".name_of_files | xargs gzip >> $LOGFILE 2>&1


    This however prints an error message:

    xargs: gzip not found


    I'm guessing this has to do with the fact that crontab executes
    scripts with sh, not ksh:

    shell> crontab -e
    warning: commands will be executed using /usr/bin/sh

    shell> echo $SHELL
    /usr/bin/ksh


    From command line the same command executes just fine, but there I am
    using ksh. So sh's xargs doesn't have gzip? Or what does this mean?
    How to get by this problem?


    I tried giving the following command:

    shell> gzip /path/to/directory/*name_of_files
    ksh: /usr/contrib/bin/gzip: arg list too long

    But as You can see, it also prints a different error message and stops
    executing. Any ideas how to solve this? Your help is very much
    appreciated.


    Thank You,

    Ville Hellman

  2. Re: xargs and gzip (crontab, ksh and sh)

    ville.hellman@gmail.com (Ville Hellman) writes:

    > I'm guessing this has to do with the fact that crontab executes
    > scripts with sh, not ksh:


    Not really.

    > From command line the same command executes just fine, but there I am
    > using ksh. So sh's xargs doesn't have gzip?


    The "xargs" is not usually a shell builtin, so there is no "sh's xarg"
    that is different from "ksh's xargs".

    > Or what does this mean?


    It means that your "gzip" is probably in /usr/local/bin and your
    PATH is not set correctly when executing from cron.

    From "man crontab":

    cron supplies a default environment for every shell, defining:

    HOME=user's-home-directory
    LOGNAME=user's-login-id
    PATH=/usr/bin:/usr/sbin:.
    SHELL=/usr/bin/sh

    Users who desire to have their .profile executed must explicitly do so
    in the crontab entry or in a script called by the entry.


    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: xargs and gzip (crontab, ksh and sh)

    Paul Pluzhnikov wrote in message news:...
    > ville.hellman@gmail.com (Ville Hellman) writes:
    >
    > > I'm guessing this has to do with the fact that crontab executes
    > > scripts with sh, not ksh:

    >
    > Not really.
    >
    > > From command line the same command executes just fine, but there I am
    > > using ksh. So sh's xargs doesn't have gzip?

    >
    > The "xargs" is not usually a shell builtin, so there is no "sh's xarg"
    > that is different from "ksh's xargs".
    >
    > > Or what does this mean?

    >
    > It means that your "gzip" is probably in /usr/local/bin and your
    > PATH is not set correctly when executing from cron.


    You're absolutely right, it was a path issue. All works now, cheers!

    -Ville



    >
    > From "man crontab":
    >
    > cron supplies a default environment for every shell, defining:
    >
    > HOME=user's-home-directory
    > LOGNAME=user's-login-id
    > PATH=/usr/bin:/usr/sbin:.
    > SHELL=/usr/bin/sh
    >
    > Users who desire to have their .profile executed must explicitly do so
    > in the crontab entry or in a script called by the entry.
    >
    >
    > Cheers,


+ Reply to Thread