--- In "j.chitte" <> wrote:
>
> Hi,
>
> I'm having what seems like some odd behaviour caused by a brown out.
>
> I have a program running to log data to a file on ram disk. I want to
> copy it to the main flash fs during an orderly shutdown so I can pick
> it up on restarting without losing data. I also have a cron job to
> back it up once an hour.
>
> I have the following as part of a script in /etc/init.d to start and
> stop the logger:
>
> case "$1" in
> start)
> echo "Starting data logger..."
> cd /www/apache
> ### recover stored adc.data if todays , ie reboot
> if (test `date|mawk '{print $2$3}'` = `ls -l /www/apache/
> htdocs/arch/adc.data | mawk '{print $6$7}'`) \
> then cp -a /www/apache/htdocs/arch/adc.data /www/apache/htdocs/
> data ; else echo "ignoring old adc.data backup" ;fi
>
> ### if -x arch/adc.data && mawk '{$2=$date} mv arch/adc.data
> htdocs/data ;
> cd /www/apache/cgi-bin
> # c/7,0/0,0/ ch7 is dac feedback, not a data channel
> /www/apache/cgi-bin/adc_logger -o /www/apache/htdocs/data/
> adc.data -c 0 -p $p -f 3 -r 3 -m 1 -T -x -a -s 1,0 2,0 3,0
> ;;
>
> stop)
> echo ""
> echo "Sending SIGHUP to adc_logger"
> echo ""
> pid=$(ps -ax | mawk '$5 ~ /adc_logger/ {print $1}' )
> echo ; echo $pid ; echo
> kill -SIGHUP $pid
> cd /www/apache/htdocs/data
> ### backup adc.data , tmpfs will lose it ###
> cp adc.data ../arch
> echo "# logger stopped at " `date`>> ../arch/adc.data
> ;;
>
>
> If I manually run stop and start on this it does what I expect.
> However, if I just pull the plug causing a brown out I get an odd
> result.
>
> I was expecting it to lose all data since the last hourly backup but
> to recover that last copy. Somehow it manages to wipe the data but
> stick in the message with date stamp.
>
> /www/apache/htdocs/data is on the ram disk, /www/apache/htdocs/arch
> is yaffs2.
>
>
> $ cat data/adc.data
>
> # logger stopped at Sun Jun 1 12:48:57 UTC 2008
> # time ch1 ch2 ch3 ch4 ch5 ch6 ch0 pump
> state
> 0
> 12:48:59 0.000 1.161 1.564 0.205 1.494 2.439 1.486 0
> 12:49:59 0.000 1.161 1.563 0.205 1.494 2.438 1.486 0
> 12:50:59 0.000 1.163 1.555 0.194 1.494 2.439 1.484 0
> 12:51:59 0.000 1.165 1.560 0.194 1.494 2.439 1.483 0
> 12:52:59 0.000 1.167 1.553 0.172 1.494 2.440 1.484 0
> 12:53:59 0.000 1.165 1.559 0.170 1.494 2.439 1.483 0
> 12:54:59 0.000 1.167 1.553 0.171 1.494 2.440 1.484 0
> 12:55:59 0.000 1.167 1.558 0.171 1.495 2.440 1.483 0
> 12:56:59 0.000 1.168 1.558 0.187 1.494 2.441 1.483 0
> 12:57:59 0.000 1.167 1.558 0.184 1.495 2.441 1.483 0
> 12:58:59 0.000 1.171 1.558 0.177 1.495 2.441 1.483 0
> 12:59:59 0.000 1.171 1.556 0.190 1.494 2.440 1.482 0
> 13:00:59 0.000 1.169 1.558 0.204 1.495 2.441 1.484 0
> 13:01:59 0.000 1.174 1.556 0.200 1.495 2.443 1.483 # logger stopped
> at Sun Jun 1 13:02:01 UTC 2008
> # time ch1 ch2 ch3 ch4 ch5 ch6 ch0 pump
> state
> 0
> 13:02:02 0.000 1.174 1.556 0.205 1.495 2.444 1.483 $
>
>
>
>
> 12:48:57 was a power off, 13:02:01 was a manual stop/start on the
> script.
>
>
> So the second established that the script does what I expect but the
> first shows that something zeroed the backup copy then wrote the date
> stamp.
>
> Now this would correspond to umounting /www/apache/htdocs/data since
> the undelying fs has a zero length adc.data.
>
> The ram disks are mounted in /etc/rc.d/rcSsysinit , my logger is
> symlinked (S and K) in rc3.d
>
> So can someone explain what is being triggered by the brown out that
> the ramdisk gets umounted before my logger gets called with stop?
>
> If I can get this to happen in the right order I can probably
> successfully write my data so it's immune to a power failure. That
> would be even better than what I set out to do.
>
> TIA.
>
Not sure if the init shutdown process will complete on a brown out.
I am looking for something similar where I log to SD an indication of
power loss before the system goes down. Once the system is back
online, I check for the power loss indication which let's the logging
process know that there is clean up to be done on the previous log files.
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|