Command produces no output if run fom cron.

Command produces no output if run fom cron.

Post by Nige » Tue, 19 Feb 2002 07:47:44



Hello,

The following command goes silent if run from cron

iptables -L -t filter -v

What I mean is if I run it manually from a command prompt it displays
soem output.  If I place it in a crontab it runs, but produces no
output.  I've tried putting it in a script, and then calling the script
from cron.  The script being.

echo start
iptables -L -t filter -v
echo end

The resulting email that cron generates reads:

start
end

I think maybe it goes quite because it has no controlling terminal(?)

Is there a way to run this command from a crontab entry and have it
produce output.

I expect (no pun intended) that running the script via expect would
solve this problem, but I'm sure there must be a simpler way without
using expect.

Nigel

 
 
 

Command produces no output if run fom cron.

Post by Tony Curti » Tue, 19 Feb 2002 07:56:31


>> On Sun, 17 Feb 2002 22:47:44 GMT,

> Hello, The following command goes silent if run from
> cron
> iptables -L -t filter -v

Guess:

Does cron know about the path to iptables?

E.g. say

    /usr/sbin/iptables ...

(or wherever you've installed it)

Quote:> What I mean is if I run it manually from a command
> prompt it displays soem output.

That means it's on the path of your login shell.  But
almost certainly not when run as a child process of cron.

Quote:> The resulting email that cron generates reads:
> start
> end

You're probably losing the "command not found" that goes
to stderr, although both stdout and stderr should end up
in the mail.

hth
t
--
Oh!  I've said too much.  Smithers, use the amnesia ray.

 
 
 

Command produces no output if run fom cron.

Post by Nige » Tue, 19 Feb 2002 08:39:07


Quote:> Does cron know about the path to iptables?

No it doesn't - you were spot on.  Problem solved - thanks.

And 9 minutes after me posting the initial question - wow!

Nigel