Command Line and Cron

Command Line and Cron

Post by John DuBo » Tue, 13 Apr 1999 04:00:00


>On HP 10.20, I am running a script which contains the following lines:

>if [ -z "$QUE" ]

>then  echo "$PROC is not started on $HOST." >> $LOG

>else if [ "$QUE" -ge $THRESHOLD ]


>navcmd start $PROC

>echo "$PROC on $HOST exceeded $THRESHOLD, additional processes were star ted
>at `date`." >> $LOG

>When I run the script from the command line (or in an "at" statement), if $QUE
>is equal to 0 (zero), then [ -z "$QUE" ] is true and the script reports

>However when I run the script from cron, if $QUE is equal to 0 (zero), then [
>-z "$QUE" ] is false and the script reports erroneous information.

>I have tried both sh and ksh on HP-UX with the same results.

Unless sh and ksh on HP-UX are terribly broken (which I doubt), you've
misinterpreted your results.  -z is used to test for whether a string has zero
length, *not* for whether it is a number with value 0.  0 is a string with
length 1, so [ -z 0 ] will always be false.  To test for whether the string is
equal to 0, use -eq 0.



1. cron fails; command line OK

I've got a puzzling problem...
I have an entry in cron as follows:
55 2 * * * find /apps/d2/outputs -name "*" -type f -mtime +7
-exec rm {} \;
Mail is sent that says "incomplete statement" and the command
does not execute.
When I execute from the command line - it works.
I think that it has not worked since we went from 3.2.5 to 4.3.2
a couple of weeks ago, although I can't imagine that would
Thanks in advance for any ideas.

2. slow sftp/scp

3. Command Line and Cron

4. VTWM-5.3 fails to read .vtwmrc

5. How to tell if script is run from cron or command line?

6. Memory Usage

7. Command Line Script runs fine get bad substititon from cron

8. Linux + Sun 3/50 + Xkernel.....would it work?

9. Crond help: Script Runs from command line, but not from cron

10. cron vs command-line

11. DIP/SLIP works great from command line, but fails as cron job (??)

12. cron & Java command line file writing/output

13. Sendmail from cron vs. command line