no data when run in crontab, but data when run manually

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
potmos
Posts: 2
Joined: Tue Jun 04, 2002 2:19 pm
Location: San Francisco, CA

no data when run in crontab, but data when run manually

Post by potmos »

i have a script below that returns remote sendmail stats by telneting to a port. on the remote machine, xinetd runs mailstats on port 88889. when i run the script on command line or when i run a manual `php ~/cmd.php` i get correct data. but when the cmd.php cronjob runs i get all U's. is there a way i can get more data in the logs? any ideas on whats wrong will be greatly appreciated.

* when run from crontab
CMD: /usr/bin/rrdtool update /var/www/html/cacti/rra/sendmail.rrd --template msgsfr:msgsto:kbfr:kbto:msgsrej:msgsdis N:U:U:U:U:U:U

* when run manually
CMD: /usr/bin/rrdtool update /var/www/html/cacti/rra/sendmail.rrd --template msgsfr:msgsto:kbfr:kbto:msgsrej:msgsdis N:3258:3542:35628:36271:0:0



#!/bin/bash

if [ $2 = relay ]; then
relay=`telnet $1 88889 | grep "^ 7"`
msgsfr=`echo $relay | awk '{print $2}'`
msgsto=`echo $relay | awk '{print $4}'`
kbfr=`echo $relay | awk '{print $3}' | cut -dK -f1`
kbto=`echo $relay | awk '{print $5}' | cut -dK -f1`
msgsrej=`echo $relay | awk '{print $6}'`
msgsdis=`echo $relay | awk '{print $7}'`

elif [ $2 = esmtp ]; then
esmtp=`telnet $1 88889 | grep "^ 4"`
msgsfr=`echo $esmtp | awk '{print $2}'`
msgsto=`echo $esmtp | awk '{print $4}'`
kbfr=`echo $esmtp | awk '{print $3}' | cut -dK -f1`
kbto=`echo $esmtp | awk '{print $5}' | cut -dK -f1`
msgsrej=`echo $esmtp | awk '{print $6}'`
msgsdis=`echo $esmtp | awk '{print $7}'`
fi

echo $msgsfr $msgsto $kbfr $kbto $msgsrej $msgsdis
User avatar
bulek
Cacti Pro User
Posts: 854
Joined: Mon May 20, 2002 2:07 am
Location: Poland
Contact:

Post by bulek »

The script has different environment ($PATH and other variables, etc.) when run from hand and as a cron job. Read more on this with "man 5 crontab". Also you can make some debugging info in your script by writing to a file variables and error checking of commands execution.
potmos
Posts: 2
Joined: Tue Jun 04, 2002 2:19 pm
Location: San Francisco, CA

Post by potmos »

i should have done a search on deja first. telnet doesnt give output when run in a cronjob
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests