Page is a not externally linkable
- Hardware and OS Related Technologies
-- Linux, Unix, and *nix like Operating Systems
---- Can't call gzip and mailx from cron


nanu - 6:31 pm on Oct 8, 2008 (gmt 0)


Hello Friends,

I am new to shell scripting and this is the first time I am trying to use cron to automate a job. The script I use generates a huge log file which I wish to mail out.

My script runs fine when called from the command line but fails to zip and mail when called from cron. Below is the script I am using

#!/bin/sh

HOME=/home/nanu
PATH=/usr/IXImotif/bin:/usr/bin/X11:/usr/openwin/bin:/usr/openwin/bin/xview:.:/home/nanu:/home/nanu/bin:/bin:/usr/local:/usr/bin:/usr/ucb:/usr/etc:/usr/newsp
rint/bin:/usr/sbin/:/usr/local/bin:/usr/omc/current/bin:/usr/omc/sbin:/usr/omc/current/sbin:/usr/informix/bin:/interleaf/iview2/bin:/opt/Wingz/bin:/usr/dt/bi
n
EDITOR=vi

##
export HOME PATH EDITOR
####
fname=`/bin/date '+active_alarms_%h%d%y_%H.xls'`

### script to generate the alarms log file goes here

#### compressing the collected report
/bin/usr/gzip $fname
####

#### mailing zipped collection report
TO="nanu@xyz.com "
(cat body; uuencode "$fname.gz" "$fname.zip") ¦ /bin/mailx -s "Active Alarms Collector Report" "$TO"
####

Please could someone tell me what I am doing wrong here? I am at my wits end as the script behaves when called from command prompt. I guess I am missing some environmental variables but which ones?


Thread source:: http://www.webmasterworld.com/linux/3761604.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com