Solved script is not executed by Cron

March 24, 2015 at 07:02:18
Specs: Solaris 10 10/08, T5240
Hi guys,

Does anyone know why the crontab's entry bellow is not being executed ?

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /var/log/claudio/conteudo_tcp_lb.sh > /dev/null 2>&1

Bellow is the content of the file:

# cat /var/log/claudio/conteudo_tcp_lb.sh

#!/bin/bash

trava=/tmp/conteudo_tcp.lck
arquivo=/var/log/estatisticas_claro/conteudo_tcp_lb_`date +%Y%m%d`.log
horario=`date "+%d%m%Y-%H%M"`

if [ ! -f "$trava" ]
then
        touch $trava
        tcpdump -i any -Xs 0 "port 10110 and ( src host 10.107.127.15 or src host 10.108.28.15 or src host 10.109.28.15 or src host 10.107.127.19 or src host 10.109.29.15 or src host 10.109.29.35 or src host 10.109.29.36 )" -c 10000 | sed 's/IP /a a a a a a a a ¨/' | awk '{ print $10 }' | tr -d "\n" | tr "¨" "\n" | grep -i responsecode | sed 's/10110.*responseCode<\/name><value><i4>//' | awk -F"</i4" '{ print $1 }' | egrep -v 'i4|Common' | awk -F"." '{ print $1"."$2"."$3"."$4" "$5 }' | sort | uniq -c | sed "s/^/${horario}/g" | awk '{ print $1","$3","$2","$4 }' >> $arquivo
        rm -rf $trava
fi

Thanks,

message edited by surfistadesampa


See More: script is not executed by Cron

Report •

#1
March 24, 2015 at 08:19:08
Have you set the shell script as executable? Have you tried running it manually?

Report •

#2
March 24, 2015 at 08:59:16
✔ Best Answer
When a program executes successfully from the command line, but not from cron it is because an environmental variable such as PATH is not set correctly. (A default PATH variable from cron is probably not the same as your user PATH variable).

In your case, I would guess that the script cannot find tcpdump. Either provide the full path to the tcpdump. i.e.

/usr/sbin/tcpdump # or where ever tcpdump is installed

or include a PATH definition in your script.

message edited by nails


Report •

#3
March 24, 2015 at 12:53:06
Nails,

You are the king !!!!

once for year i come to this forum, during years, and always have a guy that help me ... Nails !!

Thanks so much my friend !!


Report •

Related Solutions

#4
March 25, 2015 at 07:59:41
Thank you for the kind words It's much appreciated!

Report •

Ask Question