Re: [GRASS-user] Run grass console from a cronjob

2015-08-26 Thread Andrea Peri
sorry the emaiil start before end the message

I would thx for your help you and the other grass guys.

A.


2015-08-26 18:03 GMT+02:00 Nick Jachowski njachow...@gmail.com:
 I've had this problem from cron before and a solution I've found is to print
 all the environment variables using the linux command printenv.

 Run printenv from your console and from the cron then compare the output and
 see what's different.

 Then when you find the critical differences set those variables from the
 head of your bash script you use on the cron.

 sample output from printenv:
 

 vm=ubuntu.local

 AUTOJUMP_HOME=/Users/nick

 PYTHONPATH=/Users/nick/anaconda/lib/python2.7/site-packages/:/usr/local/lib/python2.7/site-packages/:

 LOGNAME=nick

 GEM_PATH=/Users/nick/.rvm/gems/ruby-2.1.1:/Users/nick/.rvm/gems/ruby-2.1.1@global

 LC_CTYPE=UTF-8

 GOPATH=/Users/nick/Copy/libs/gocode

 ARCHFLAGS=-arch x86_64


 On Wed, Aug 26, 2015 at 10:27 PM, Andrea Peri aperi2...@gmail.com wrote:

 Hi,

 I'm try to run a grass session from a cronjob
 The cron execut a bash script where I try to execute

 grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

 If I try the bash script from a console it run good and without any
 problem.
 Bu if I try to execute the script from a crontab.
 It stop to execute when try to do:

 grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

 Is the grass suitable for a cronjob ?

 Thx,

 --
 -
 Andrea Peri
 . . . . . . . . .
 qwerty àèìòù
 -
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user





-- 
-
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Run grass console from a cronjob

2015-08-26 Thread Andrea Peri
I found the solution with the printenv.

My script was for bash-shell, but the crontab instead start a sh-shell.

Thx for help you and other grass guys.

A.


2015-08-26 22:09 GMT+02:00 Andrea Peri aperi2...@gmail.com:
 sorry the emaiil start before end the message

 I would thx for your help you and the other grass guys.

 A.


 2015-08-26 18:03 GMT+02:00 Nick Jachowski njachow...@gmail.com:
 I've had this problem from cron before and a solution I've found is to print
 all the environment variables using the linux command printenv.

 Run printenv from your console and from the cron then compare the output and
 see what's different.

 Then when you find the critical differences set those variables from the
 head of your bash script you use on the cron.

 sample output from printenv:
 

 vm=ubuntu.local

 AUTOJUMP_HOME=/Users/nick

 PYTHONPATH=/Users/nick/anaconda/lib/python2.7/site-packages/:/usr/local/lib/python2.7/site-packages/:

 LOGNAME=nick

 GEM_PATH=/Users/nick/.rvm/gems/ruby-2.1.1:/Users/nick/.rvm/gems/ruby-2.1.1@global

 LC_CTYPE=UTF-8

 GOPATH=/Users/nick/Copy/libs/gocode

 ARCHFLAGS=-arch x86_64


 On Wed, Aug 26, 2015 at 10:27 PM, Andrea Peri aperi2...@gmail.com wrote:

 Hi,

 I'm try to run a grass session from a cronjob
 The cron execut a bash script where I try to execute

 grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

 If I try the bash script from a console it run good and without any
 problem.
 Bu if I try to execute the script from a crontab.
 It stop to execute when try to do:

 grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

 Is the grass suitable for a cronjob ?

 Thx,

 --
 -
 Andrea Peri
 . . . . . . . . .
 qwerty àèìòù
 -
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user





 --
 -
 Andrea Peri
 . . . . . . . . .
 qwerty àèìòù
 -



-- 
-
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Run grass console from a cronjob

2015-08-26 Thread Vaclav Petras
On Wed, Aug 26, 2015 at 4:12 PM, Andrea Peri aperi2...@gmail.com wrote:

 My script was for bash-shell, but the crontab instead start a sh-shell.

Script should have a shebang and this should solve the interpreter problem
for you, i.e. you can use any interpreter available as long as you specify
it in the shebang line.

Best,
Vaclav

https://en.wikipedia.org/wiki/Shebang_%28Unix%29
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Run grass console from a cronjob

2015-08-26 Thread Andrea Peri
Hi,
thx for help Vaclav

I was trying to run a shell script with a start of a grass and many
grass command inside it.
Not only a grass call.

As reported few minutes ago,
I resolve my issue .
Printing the environment variables (using the printenv utility)
I see that the crontab start a sh-shell, but my script was for a bash.shell.

So the solution was simply to add the usually.
#!/bin/bash
in the head of script.

Regards and thx to all for your help.

A.


2015-08-26 22:14 GMT+02:00 Vaclav Petras wenzesl...@gmail.com:
 I've seen your email about wrong shell but anyway:

 On Wed, Aug 26, 2015 at 10:47 AM, Andrea Peri aperi2...@gmail.com wrote:

 I have some relative path, but my first
 line in bash is a

  cd /home/--path-to-grass-position 

 to set the script in the right position in filesystem.

 What you actually have in the crontab? Script or a grass70 call? Both should
 work anyway. Usually you have some script in any case. Either it is a
 general script and you call it from crontab and then call GRASS from there
 in some way or you have a script for GRASS and you call `grass` with the
 script (see below).

 For 7.0 the (way too short (please contribute)) documentation is:

 https://grass.osgeo.org/grass70/manuals/grass7.html#running-non-interactive-batch-jobs

 For trunk/7.1 there is one other option:

 https://grass.osgeo.org/grass71/manuals/grass7.html#exec-interface-example



-- 
-
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Run grass console from a cronjob

2015-08-26 Thread Vaclav Petras
I've seen your email about wrong shell but anyway:

On Wed, Aug 26, 2015 at 10:47 AM, Andrea Peri aperi2...@gmail.com wrote:

 I have some relative path, but my first
 line in bash is a

  cd /home/--path-to-grass-position 

 to set the script in the right position in filesystem.

What you actually have in the crontab? Script or a grass70 call? Both
should work anyway. Usually you have some script in any case. Either it is
a general script and you call it from crontab and then call GRASS from
there in some way or you have a script for GRASS and you call `grass` with
the script (see below).

For 7.0 the (way too short (please contribute)) documentation is:

https://grass.osgeo.org/grass70/manuals/grass7.html#running-non-interactive-batch-jobs

For trunk/7.1 there is one other option:

https://grass.osgeo.org/grass71/manuals/grass7.html#exec-interface-example
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Run grass console from a cronjob

2015-08-26 Thread Nick Jachowski
I've had this problem from cron before and a solution I've found is to
print all the environment variables using the linux command printenv.

Run printenv from your console and from the cron then compare the output
and see what's different.

Then when you find the critical differences set those variables from the
head of your bash script you use on the cron.

sample output from printenv:


vm=ubuntu.local

AUTOJUMP_HOME=/Users/nick

PYTHONPATH=/Users/nick/anaconda/lib/python2.7/site-packages/:/usr/local/lib/python2.7/site-packages/:

LOGNAME=nick

GEM_PATH=/Users/nick/.rvm/gems/ruby-2.1.1:/Users/nick/.rvm/gems/ruby-2.1.1@global

LC_CTYPE=UTF-8

GOPATH=/Users/nick/Copy/libs/gocode

ARCHFLAGS=-arch x86_64

On Wed, Aug 26, 2015 at 10:27 PM, Andrea Peri aperi2...@gmail.com wrote:

 Hi,

 I'm try to run a grass session from a cronjob
 The cron execut a bash script where I try to execute

 grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

 If I try the bash script from a console it run good and without any
 problem.
 Bu if I try to execute the script from a crontab.
 It stop to execute when try to do:

 grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

 Is the grass suitable for a cronjob ?

 Thx,

 --
 -
 Andrea Peri
 . . . . . . . . .
 qwerty àèìòù
 -
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Run grass console from a cronjob

2015-08-26 Thread Blumentrath, Stefan
Hi,

Did you provide full paths?
E.g. ~/my.tif would not work for cronjobs, you would have to use 
/home/user/my.tif instead.

Not sure if also the path to the command to execute has to be complete (e.g. 
/bin/grass70 ...)...

Cheers
Stefan


-Original Message-
From: grass-user-boun...@lists.osgeo.org 
[mailto:grass-user-boun...@lists.osgeo.org] On Behalf Of Andrea Peri
Sent: 26. august 2015 16:27
To: GRASS user list grass-user@lists.osgeo.org
Subject: [GRASS-user] Run grass console from a cronjob

Hi,

I'm try to run a grass session from a cronjob The cron execut a bash script 
where I try to execute

grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

If I try the bash script from a console it run good and without any problem.
Bu if I try to execute the script from a crontab.
It stop to execute when try to do:

grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

Is the grass suitable for a cronjob ?

Thx,

--
-
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Run grass console from a cronjob

2015-08-26 Thread Andrea Peri
Hi, thx for reply.

I guess yes.
I have some relative path, but my first
line in bash is a

 cd /home/--path-to-grass-position 

to set the script in the right position in filesystem.

Also in the script I set these env vars.

  export HOME=/home/path-to-home
  export USER=the_user
  export GROUP=the_group

to the right user and group for grass

A.


2015-08-26 16:38 GMT+02:00 Blumentrath, Stefan stefan.blumentr...@nina.no:
 Hi,

 Did you provide full paths?
 E.g. ~/my.tif would not work for cronjobs, you would have to use 
 /home/user/my.tif instead.

 Not sure if also the path to the command to execute has to be complete (e.g. 
 /bin/grass70 ...)...

 Cheers
 Stefan


 -Original Message-
 From: grass-user-boun...@lists.osgeo.org 
 [mailto:grass-user-boun...@lists.osgeo.org] On Behalf Of Andrea Peri
 Sent: 26. august 2015 16:27
 To: GRASS user list grass-user@lists.osgeo.org
 Subject: [GRASS-user] Run grass console from a cronjob

 Hi,

 I'm try to run a grass session from a cronjob The cron execut a bash script 
 where I try to execute

 grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

 If I try the bash script from a console it run good and without any problem.
 Bu if I try to execute the script from a crontab.
 It stop to execute when try to do:

 grass70 -text -c /path-to-geotiff/file.tif -e /grassdata/mapset_location

 Is the grass suitable for a cronjob ?

 Thx,

 --
 -
 Andrea Peri
 . . . . . . . . .
 qwerty àèìòù
 -
 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user



-- 
-
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Run grass console from a cronjob

2015-08-26 Thread Hermann Peifer

On 2015-08-26 16:27, Andrea Peri wrote:

Hi,

I'm try to run a grass session from a cronjob
The cron execut a bash script where I try to execute



Do you know GRASS_BATCH_JOBs? They run fine, AFAICT. Hermann

https://grasswiki.osgeo.org/wiki/GRASS_and_Shell#GRASS_Batch_jobs

___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user