[OpenIndiana-discuss] command will not run from cron but will from CLI

2016-05-09 Thread david
I have not been able to get even a simple command to run from cron.  For a
test I created this script:

#!/bin/sh

export PATH="/usr/bin:/usr/sbin:/root"
/bin/echo "test" > /root/test.log

It runs from the command line but does not from cron:

55 11 9 * * * /root/test

The log shows:

>  CMD: * /root/test
>  root 17987 c Mon May  9 11:55:00 2016
<  root 17987 c Mon May  9 11:55:00 2016 rc=127

Also see:
# ls -l /root/test
-rwxr-xr-x   1 root root  85 May  9 11:57 /root/test


Looks like it cannot fork but /bin/sh, /bin/echo and /root/test all work
from the command line.  What am I missing?

Regards,
David Koski



___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
http://openindiana.org/mailman/listinfo/openindiana-discuss


Re: [OpenIndiana-discuss] command will not run from cron but will from CLI

2016-05-09 Thread James Carlson
On 05/09/16 15:01, da...@kosmosisland.com wrote:
> I have not been able to get even a simple command to run from cron.  For a
> test I created this script:
> 
> #!/bin/sh
> 
> export PATH="/usr/bin:/usr/sbin:/root"
> /bin/echo "test" > /root/test.log
> 
> It runs from the command line but does not from cron:
> 
> 55 11 9 * * * /root/test
> 
> The log shows:
> 
>>  CMD: * /root/test
>>  root 17987 c Mon May  9 11:55:00 2016
> <  root 17987 c Mon May  9 11:55:00 2016 rc=127
> 
> Also see:
> # ls -l /root/test
> -rwxr-xr-x   1 root root  85 May  9 11:57 /root/test
> 
> 
> Looks like it cannot fork but /bin/sh, /bin/echo and /root/test all work
> from the command line.  What am I missing?

At a guess, it's saying "PATH=/usr/bin:/usr/sbin:/root: is not an
identifier".

Try either:

PATH=/usr/bin:/usr/sbin:/root
export PATH

or:

#!/bin/ksh

-- 
James Carlson 42.703N 71.076W 

___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
http://openindiana.org/mailman/listinfo/openindiana-discuss


Re: [OpenIndiana-discuss] command will not run from cron but will from CLI

2016-05-09 Thread Rich Teer
On Mon, 9 May 2016, da...@kosmosisland.com wrote:

> I have not been able to get even a simple command to run from cron.  For a
> test I created this script:
> 
> #!/bin/sh
> 
> export PATH="/usr/bin:/usr/sbin:/root"

/bin/sh doesn't support that nomenclature for exporting variables;
you have to define them in one statement and export them in another.
For example:

PATH="/usr/bin:/usr/sbin:/root"
export PATH

-- 
Rich Teer, Publisher
Vinylphile Magazine

www.vinylphilemag.com

___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
http://openindiana.org/mailman/listinfo/openindiana-discuss


Re: [OpenIndiana-discuss] command will not run from cron but will from CLI

2016-05-09 Thread Peter Tribble
On Mon, May 9, 2016 at 8:01 PM,  wrote:

> I have not been able to get even a simple command to run from cron.  For a
> test I created this script:
>
> #!/bin/sh
>
> export PATH="/usr/bin:/usr/sbin:/root"
> /bin/echo "test" > /root/test.log
>
> It runs from the command line but does not from cron:
>
> 55 11 9 * * * /root/test
>
> The log shows:
>
> >  CMD: * /root/test
> >  root 17987 c Mon May  9 11:55:00 2016
> <  root 17987 c Mon May  9 11:55:00 2016 rc=127
>

It's not the script, it's your crontab entry.

The command it's trying to run (see the CMD in the log) is

* /root/test

and, indeed, where there should be 5 time specifiers in the crontab entry
you have 6:

55 11 9 * * *

-- 
-Peter Tribble
http://www.petertribble.co.uk/ - http://ptribble.blogspot.com/
___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
http://openindiana.org/mailman/listinfo/openindiana-discuss


Re: [OpenIndiana-discuss] command will not run from cron but will from CLI

2016-05-09 Thread david
> On Mon, May 9, 2016 at 8:01 PM,  wrote:
>
>> I have not been able to get even a simple command to run from cron.  For
>> a
>> test I created this script:
>>
>> #!/bin/sh
>>
>> export PATH="/usr/bin:/usr/sbin:/root"
>> /bin/echo "test" > /root/test.log
>>
>> It runs from the command line but does not from cron:
>>
>> 55 11 9 * * * /root/test
>>
>> The log shows:
>>
>> >  CMD: * /root/test
>> >  root 17987 c Mon May  9 11:55:00 2016
>> <  root 17987 c Mon May  9 11:55:00 2016 rc=127
>>
>
> It's not the script, it's your crontab entry.
>
> The command it's trying to run (see the CMD in the log) is
>
> * /root/test
>
> and, indeed, where there should be 5 time specifiers in the crontab entry
> you have 6:
>
> 55 11 9 * * *

I was blinded by my frustration.  Thank you, Peter!

David Koski

>
> --
> -Peter Tribble
> http://www.petertribble.co.uk/ - http://ptribble.blogspot.com/



___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
http://openindiana.org/mailman/listinfo/openindiana-discuss