Linux Bash Scripting help needed

alexandra123

Registered User
Messages
282
Hello,

Just wondering if anyone out there has any linux experience and can help me on the below - I am actually using Ubuntu , but it should not matter a great deal.


I created a cron job.
The cron job is running a bash.sh file every couple of minutes.
I need the bash.sh file to look at a conf file and read the status of the conf file to a log file.

Bash file code
cat 'etc/mon.conf' | more
while read line; do
echo cat "$line" >> /var/log/mon.log
done
fi
fi

mon.conf code
ps ax | grep bluetooth |grep -v grep

How do I get the bash file to read the conf file and print the service status to the log file ????

Thanks in advance
 
Your just trying to append one file to another each time ?

If so think you are over thinking it.


This one line should do it :


cat mon.conf >> /var/log/mon.log
 
Thanks guys for the responses so far.

I actually need to print the output of the service into the log file.
for example the
ps ax | grep bluetooth |grep -v grep
should actually tell me if the service is started or stopped.

I need this status information printed to the log file. So the result would be something like
status bluetooth started

Would this help
cat 'etc/mon.conf' | more | while read line;
do
echo eval "$line" >> /var/log/mon.log
fi
done

I have added eval - to evaluate the result of the grep command ...
 
Try the script here (just replace the append the log files instead of printing to screen).
 
Back
Top