Article 56ATR Bash script not working with Cron

Bash script not working with Cron

by
AlessioGiberti
from LinuxQuestions.org on (#56ATR)
Hi, I wrote a bash script that sniffs the net traffic on one specific port. Its job is to send an alert via mail, using ssmtp, in case the traffic stops.
The issue is that if I run the script via shellCode:>>sh myscript.sh it works perfectly, while if I schedule its execution with crontab it doesn't work.

Code:#!/bin/bash

unset a

a=$(/usr/bin/timelimit -t10 /usr/sbin/tcpdump -i any -A -nn port 1883 and not host 192.168.183.58)

if [ -z "$a" ];
then
echo Non ho ricevuto niente!
/usr/sbin/ssmtp giberti@laboratoriomister.it < /home/alessio/text4CrisalideAlert.txt
fiAs you can see, I specified the complete paths for the external tools (timilimit, tcpdump and ssmtp). Looking at journalctl the issue seems to be 550 invalid domain. But launching it by hand it works!

Any help please?latest?d=yIl2AUoC8zA latest?i=rRvnJxD9KSw:khZixxQSR4M:F7zBnMy latest?i=rRvnJxD9KSw:khZixxQSR4M:V_sGLiP latest?d=qj6IDK7rITs latest?i=rRvnJxD9KSw:khZixxQSR4M:gIN9vFwrRvnJxD9KSw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments