What I understand from the script, cron does run below part(bold part). cron has having problem to run for loop. that have to check.
#!/bin/bash
ls -altrh /syslog --time-style=+%D | grep $(date +%D) |awk '{print $7'} >output.txt
echo -e "SYSLOG Status on Date- `date '+%A %d-%B, %Y'`">output1.txt
echo "------------------------------------------------------------------------------------------------">>output1.txt
echo -e "HostName \t\t\t Status ">>output1.txt
echo "------------------------------------------------------------------------------------------------">>output1.txt
for hosts in `cat hosts.txt`;
do
output=$(grep -i -w $hosts output.txt)
if [ $? == 0 ] ;
then
echo -e "$hosts \t\t Log Received">>output1.txt
else
echo -e "$hosts \t\t Log Not-Received">>output1.txt
sleep 5
fi
done
mailx -s "Syslog-Status------Date-`date '+%A %d-%B, %Y'`" abc@abc.com<output1.txt
```[/b]
--- Post updated at 03:50 PM ---
Hi Neo,
sorry unable to understand.
you mean to provide full path, like bold?
```text
for hosts in `cat /usr/local/scripts/hosts.txt`;
do
output=$(grep -i -w $hosts /usr/local/scripts/output.txt)
if [ $? == 0 ] ;
then
echo -e "$hosts \t\t Log Received">>/usr/local/scripts/output1.txt
else
echo -e "$hosts \t\t Log Not-Received">>/usr/local/scripts/output1.txt
sleep 5
fi
--- Post updated at 03:50 PM ---
Hi Neo,
sorry unable to understand.
you mean to provide full path, like bold?
for hosts in `cat /usr/local/scripts/hosts.txt`;
do
output=$(grep -i -w $hosts /usr/local/scripts/output.txt)
if [ $? == 0 ] ;
then
echo -e "$hosts \t\t Log Received">>/usr/local/scripts/output1.txt
else
echo -e "$hosts \t\t Log Not-Received">>/usr/local/scripts/output1.txt
sleep 5
fi
--- Post updated at 03:53 PM ---
Hi Neo,
sorry unable to understand.
you mean to provide full path, like bold?
for hosts in `cat /usr/local/scripts/hosts.txt`;
do
output=$(grep -i -w $hosts /usr/local/scripts/output.txt)
if [ $? == 0 ] ;
then
echo -e "$hosts \t\t Log Received">>/usr/local/scripts/output1.txt
else
echo -e "$hosts \t\t Log Not-Received">>/usr/local/scripts/output1.txt
sleep 5
fi
--- Post updated at 03:56 PM ---
Wonderful Neo. thanks for suggestion. issue is resolved. now able to get mail.
Thank you so much sir. how to makr this case as resolve?
--- Post updated at 03:59 PM ---
Wonderful Neo. thanks for suggestion. issue is resolved. now able to get mail.
Thank you so much sir. how to make this case as resolve?