Running Shell Script for grib2ctl /gribmap on crontab
Eric Altshuler
ela at COLA.IGES.ORG
Thu Nov 13 20:03:06 EST 2008
Zilore,
The grib2ctl.pl script requires wgrib to be in the user's path. When a job runs under cron, the environment (including the path) is usually different than if you run the job from an interactive login. Often, the PATH for a cron job will not include $HOME/bin or '.', and sometimes /usr/local/bin is not included either. Even though you provide full paths for grib2ctl.pl and gribmap, it is likely that grib2ctl.pl cannot find the wgrib executable. There are two things you could do:
1. Find the directory where the wgrib executable is located on your system, and add it to the PATH environment variable, e.g. if it is in /usr/local/grads/bin, then add this line near the beginning of your script:
export PATH=/usr/local/grads/bin:$PATH
2. Alternatively, edit the grib2ctl.pl script and look for the following line:
$wgrib='wgrib';
Change this to:
$wgrib='/usr/local/grads/bin/wgrib';
or wherever wgrib is located on your system.
Best regards,
Eric L. Altshuler
Assistant Research Scientist
Center for Ocean-Land-Atmosphere Studies
4041 Powder Mill Road, Suite 302
Calverton, MD 20705-3106
USA
E-mail: ela at cola.iges.org
Phone: (301) 902-1257
Fax: (301) 595-9793
----- Original Message -----
From: "zilore mumba" <zmumba at YAHOO.COM>
To: GRADSUSR at LIST.CINECA.IT
Sent: Thursday, November 13, 2008 2:08:08 AM GMT -05:00 US/Canada Eastern
Subject: Running Shell Script for grib2ctl /gribmap on crontab
Sincere apologies as my question is not purely Grads. I have a shell script (code below) which:
1. concatenates files via the cat command;
2. runs grib2ctl to create a ctl
3. run gribmap
When I run the script manually (i.e. on the command line) it performs as required.
When I run it through crontab, it concatenates files ok, but it creates a ctl file which is empty and it does not create an idx file (even though I have indicated the paths to where grib2ctl and gribmap are located)
Assistance will be appreciated.
Zilore.
Â
#
#!/bin/bash
#This script processes UKMO model data from RETIM-SYNERGIE and archives it on
#the ACMAD system. The cycles (or times) are 00 and 12.
#
ctl_ext=".ctl"
grib_ext=".grib"
UK_sufx="2"
dash="-"
model="ukmo"
#
model_dat=`date "+%Y%m%d"`
model_hr=`date "+%H"`
#
model_dat1=$( date -d "1 day" "+%Y%m%d" )
#
model_mon=`date "+%m"`
mon_name=`date "+%B"`
yr=`date "+%y"`
#
if [ $model_hr -gt "15" ]
 then
   cycle="12"
else
   cycle="00"
fi
#
base_dir="/home/Mumba/archive/$model_mon$dash$mon_name$yr"
#
     cd $base_dir/$model/$model_dat
#Â Â Â Â Â pwd
     cat *H > $model$cycle$grib_ext
     /usr/local/bin/grib2ctl.pl -verf $model$cycle$grib_ext > $model$cycle$ctl_ext
     /usr/local/grads/bin/gribmap -i $model$cycle$ctl_ext -v -e
     rm *H
 #
     mv $base_dir/$model/$model_dat1/*H $base_dir/$model/$model_dat
     cat *H > $model$cycle$UK_suf$grib_ext
     /usr/local/bin/grib2ctl.pl -verf $model$cycle$UK_sufx$grib_ext > $model$cycle$UK_sufx$ctl_ext
     /usr/local/grads/bin/gribmap -i $model$cycle$UK_sufx$ctl_ext -v -e
     rm *H
  #
#
date
exit 0
More information about the gradsusr
mailing list