This should create a file named "probe0001" which contains a value from your proc file. It will probe it all the time as soon as it can and should only create a new file when the value has changed.
That is fresh, but the first thing that comes in my mind why copy the contens of a file to another file.
An advantage of this way is that the step times of reading and processing are seperate.
owfs has some way for this too, it has an uncached directory and the cached (normal) dir is refreshed whenever the uncached is accessed, so a read every XXXms would also refresh the normal reading.
The second script is something i would do like this:
while [ true ]; do
file_1=$(ls --color=no /path/to/probe/files/probe_1* | head -n1)
file_2=$(ls --color=no /path/to/probe/files/probe_2* | head -n1)
Do what ever you want with content_1 and content_2
Hope this is a better way of doing it
It's atleast what i would've done.
I have tried a while to, but the problem is the processing lines beneeth it, there have to be done some calculations for every sensor and all of them together is giving some "lag" and therefore making the rpm reading/calculation unreliable.
That was the main reason for using pid and wait.
At the moment I have almost the same running without the wait function and it does 47 readings per minute but that means the rpm calculation is not reliable so I need to grab it all in a fixed timeframe.
Here the full script as I have so far:
export LANG LC_ALL
time_step=$(sleep 1) &
time_stamp=$(date +%y%m%d%H%M%S) &
rpm_eng=$(echo "scale=0;($rpm_1/1)*60/2" | bc)
counter_1=$(cat /tmp/owfs/1D.E4D90D000000/counters.A) &
pres_trb_air=$(echo "scale=2;(-0.5*($pres_trb_air*$pres_trb_air)+0.2*$pres_trb_air+7)*100" | bc) &
pres_eng_oil=$(echo "scale=2;(0.84*($pres_eng_oil*$pres_eng_oil)+-0.2*$pres_eng_oil+0.5)*100" | bc) &
temp_cyl_1=$(echo "scale=0;$(cat /tmp/owfs/30.03DD95110000/typeK/temperature)/1" | bc) &
temp_cyl_2=$(echo "scale=0;$(cat /tmp/owfs/30.5FDF95110000/typeK/temperature)/1" | bc) &
temp_cyl_3=$(echo "scale=0;$(cat /tmp/owfs/30.4CE495110000/typeK/temperature)/1" | bc) &
temp_cyl_4=$(echo "scale=0;$(cat /tmp/owfs/30.08DD95110000/typeK/temperature)/1" | bc) &
temp_trb_air=$(echo "scale=0;$(cat /tmp/owfs/30.ADDD95110000/typeK/temperature)/1" | bc) &
wait $time_step_pid $time_stamp_pid $temp_cyl_1_pid $temp_cyl_2_pid $temp_cyl_3_pid $temp_cyl_4_pid $temp_trb_air_pid $pres_trb_air_pid $temp_eng_oil_pid $pres_eng_oil_pid $rpm_eng_pid
CMD="mysql -u root dlogger -e \"insert into samples values ($values)\""
# `eval $CMD`
while [ 1 ]