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
Re: xargs and gzip (crontab, ksh and sh)
[email]ville.hellman@gmail.com[/email] (Ville Hellman) writes:
[color=blue]
> I'm guessing this has to do with the fact that crontab executes
> scripts with sh, not ksh:[/color]
Not really.
[color=blue]
> From command line the same command executes just fine, but there I am
> using ksh. So sh's xargs doesn't have gzip?[/color]
The "xargs" is not usually a shell builtin, so there is no "sh's xarg"
that is different from "ksh's xargs".
[color=blue]
> Or what does this mean?[/color]
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.
Re: xargs and gzip (crontab, ksh and sh)
Paul Pluzhnikov <ppluzhnikov-nsp@charter.net> wrote in message news:<m3ekbgsr5l.fsf@amoeba.parasoft.com>...[color=blue]
> [email]ville.hellman@gmail.com[/email] (Ville Hellman) writes:
>[color=green]
> > I'm guessing this has to do with the fact that crontab executes
> > scripts with sh, not ksh:[/color]
>
> Not really.
>[color=green]
> > From command line the same command executes just fine, but there I am
> > using ksh. So sh's xargs doesn't have gzip?[/color]
>
> The "xargs" is not usually a shell builtin, so there is no "sh's xarg"
> that is different from "ksh's xargs".
>[color=green]
> > Or what does this mean?[/color]
>
> It means that your "gzip" is probably in /usr/local/bin and your
> PATH is not set correctly when executing from cron.[/color]
You're absolutely right, it was a path issue. All works now, cheers!
-Ville
[color=blue]
>
> 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,[/color]