line numbers are not sent to custom log file.
by linuxgirl94 from LinuxQuestions.org on (#5RZNA)
Hello!
I am making a bash script, that will serve as a daemon. What i need to do is to send a line number,timestamp, and a message whenever another file (testfile) has been changed or modified to my custom log file.
The problem is that the line numbers are not showing up in the log file along with the timestamp and the change message.
my script right now:
Code:#!/bin/bash
LTIME=`stat -c %y /var/testfil1`
while true
do
ATIME=`stat -c %y /var/testfil1`
if [[ "$ATIME" != "$LTIME" ]]
then
j=1
for i in `cat /var/testfil1`
do
j=$((j+1))
echo "$j" `date` : "Andringar har gjorts.">>/var/log/loggfil;
done
LTIME=$ATIME
fi
let j+=1
sleep 10
done
I am making a bash script, that will serve as a daemon. What i need to do is to send a line number,timestamp, and a message whenever another file (testfile) has been changed or modified to my custom log file.
The problem is that the line numbers are not showing up in the log file along with the timestamp and the change message.
my script right now:
Code:#!/bin/bash
LTIME=`stat -c %y /var/testfil1`
while true
do
ATIME=`stat -c %y /var/testfil1`
if [[ "$ATIME" != "$LTIME" ]]
then
j=1
for i in `cat /var/testfil1`
do
j=$((j+1))
echo "$j" `date` : "Andringar har gjorts.">>/var/log/loggfil;
done
LTIME=$ATIME
fi
let j+=1
sleep 10
done