Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #12494 > unrolled thread

HOW2 capture time of power-failure?

Started bynot.socialnetwork@gmail.com
First post2014-10-26 17:38 +0000
Last post2014-11-08 03:32 +0000
Articles 20 on this page of 32 — 13 participants

Back to article view | Back to comp.os.linux.misc


Contents

  HOW2 capture time of power-failure? not.socialnetwork@gmail.com - 2014-10-26 17:38 +0000
    Re: HOW2 capture time of power-failure? Ian Malcolm <See.My.Sig.for.email@totally.invalid> - 2014-10-26 18:26 +0000
      Re: HOW2 capture time of power-failure? not.socialnetwork@gmail.com - 2014-10-27 18:10 +0000
        Re: HOW2 capture time of power-failure? Gordon Henderson <gordon+usenet@drogon.net> - 2014-10-27 18:29 +0000
          Re: HOW2 capture time of power-failure? not.socialnetwork@gmail.com - 2014-10-28 21:26 +0000
        Re: HOW2 capture time of power-failure? William Unruh <unruh@invalid.ca> - 2014-10-28 04:56 +0000
          Re: HOW2 capture time of power-failure? Dom <domafp@blueyonder.co.uk> - 2014-10-28 06:29 +0000
            Re: HOW2 capture time of power-failure? William Unruh <unruh@invalid.ca> - 2014-10-28 06:41 +0000
              Re: HOW2 capture time of power-failure? not.socialnetwork@gmail.com - 2014-10-29 00:12 +0000
    Re: HOW2 capture time of power-failure? William Unruh <unruh@invalid.ca> - 2014-10-26 19:23 +0000
      Re: HOW2 capture time of power-failure? spam-no-spam@Freeola.net.invalid (Windmill) - 2014-11-04 13:19 +0000
        Re: HOW2 capture time of power-failure? William Unruh <unruh@invalid.ca> - 2014-11-05 21:56 +0000
          Re: HOW2 capture time of power-failure? Joe Beanfish <joebeanfish@nospam.duh> - 2014-11-06 14:12 +0000
          Re: HOW2 capture time of power-failure? nba@users.sourceforge.net (Niels Baggesen) - 2014-11-06 16:15 +0100
            Re: HOW2 capture time of power-failure? William Unruh <unruh@invalid.ca> - 2014-11-06 16:00 +0000
          Re: HOW2 capture time of power-failure? spam-no-spam@Freeola.net.invalid (Windmill) - 2014-11-06 20:37 +0000
        Re: HOW2 capture time of power-failure? Joe Beanfish <joebeanfish@nospam.duh> - 2014-11-06 14:13 +0000
    Re: HOW2 capture time of power-failure? andrew@cucumber.demon.co.uk (Andrew Gabriel) - 2014-10-26 20:28 +0000
    Re: HOW2 capture time of power-failure? Joe Beanfish <joebeanfish@nospam.duh> - 2014-10-27 13:17 +0000
    Re: HOW2 capture time of power-failure? Jean-David Beyer <jeandavid8@verizon.net> - 2014-10-28 13:43 -0400
      Re: HOW2 capture time of power-failure? Ant <ant@zimage.comANT> - 2014-10-29 08:18 -0700
    Re: HOW2 capture time of power-failure? Joe Beanfish <joebeanfish@nospam.duh> - 2014-10-29 13:28 +0000
      Re: HOW2 capture time of power-failure? not.socialnetwork@gmail.com - 2014-10-30 08:32 +0000
        background processes (was HOW2 capture time of power-failure?) Joe Beanfish <joebeanfish@nospam.duh> - 2014-10-30 13:16 +0000
          Re: background processes (was HOW2 capture time of power-failure?) not.socialnetwork@gmail.com - 2014-11-03 03:25 +0000
            Re: background processes (was HOW2 capture time of power-failure?) "David W. Hodgins" <dwhodgins@nomail.afraid.org> - 2014-11-02 23:34 -0500
            Re: background processes (was HOW2 capture time of power-failure?) William Unruh <unruh@invalid.ca> - 2014-11-03 08:25 +0000
            Re: background processes (was HOW2 capture time of power-failure?) Martin Gregorie <martin@address-in-sig.invalid> - 2014-11-03 12:56 +0000
              Re: background processes (was HOW2 capture time of power-failure?) not.socialnetwork@gmail.com - 2014-11-06 19:19 +0000
                Re: background processes (was HOW2 capture time of power-failure?) Martin Gregorie <martin@address-in-sig.invalid> - 2014-11-07 02:36 +0000
                Re: background processes (was HOW2 capture time of power-failure?) Joe Beanfish <joebeanfish@nospam.duh> - 2014-11-07 14:28 +0000
                  Re: background processes (was HOW2 capture time of power-failure?) not.socialnetwork@gmail.com - 2014-11-08 03:32 +0000

Page 1 of 2  [1] 2  Next page →


#12494 — HOW2 capture time of power-failure?

Fromnot.socialnetwork@gmail.com
Date2014-10-26 17:38 +0000
SubjectHOW2 capture time of power-failure?
Message-ID<m2jbi3$geq$1@dont-email.me>
I need to capture the time-after-a-sound-file-starts-playing
until the power is cut, with a resolution of 30 secs., over a
period of 30 minutes.

While `ogg123  SoundFie.ogg` is playing, could the play-time
be updated every 30 secs?  How?

== TIA.

PS. power-cuts without `umount` are no problem for rPi's
SD nor USBstik.

[toc] | [next] | [standalone]


#12495

FromIan Malcolm <See.My.Sig.for.email@totally.invalid>
Date2014-10-26 18:26 +0000
Message-ID<XnsA3D2BB8ABDCA70xDEADBEEF@213.239.209.88>
In reply to#12494
not.socialnetwork@gmail.com wrote in news:m2jbi3$geq$1@dont-email.me:

> I need to capture the time-after-a-sound-file-starts-playing
> until the power is cut, with a resolution of 30 secs., over a
> period of 30 minutes.
> 
> While `ogg123  SoundFie.ogg` is playing, could the play-time
> be updated every 30 secs?  How?
> 
> == TIA.
> 
> PS. power-cuts without `umount` are no problem for rPi's
> SD nor USBstik.

However a power failure in the middle of a write commonly corrupts SD 
cards and in some cases has been known to make them unusable.

Most RTC chips have a small amount of battery backed scratchpad RAM.  
Store timestamps for the start time + the current time in the scratchpad 
and update at least every 30 seconds.   Due to the risk of a power 
failure while updating the current time, you should use a checksum and 
use two different locations, alternating between them.

The details of how to implement this in a Python script will depend on 
the chip on your RTC module . . . .
-- 
Ian Malcolm.   London, ENGLAND.  (NEWSGROUP REPLY PREFERRED) 
ianm[at]the[dash]malcolms[dot]freeserve[dot]co[dot]uk 
[at]=@, [dash]=- & [dot]=. *Warning* HTML & >32K emails --> NUL

[toc] | [prev] | [next] | [standalone]


#12529

Fromnot.socialnetwork@gmail.com
Date2014-10-27 18:10 +0000
Message-ID<m2m1rf$6bh$1@dont-email.me>
In reply to#12495
In article <XnsA3D2BB8ABDCA70xDEADBEEF@213.239.209.88>, Ian Malcolm <See.My.Sig.for.email@totally.invalid> wrote: 

> not.socialnetwork@gmail.com wrote in news:m2jbi3$geq$1@dont-email.me:
> 
> > I need to capture the time-after-a-sound-file-starts-playing
> > until the power is cut, with a resolution of 30 secs., over a
> > period of 30 minutes.
> > 
> > While `ogg123  SoundFie.ogg` is playing, could the play-time
> > be updated every 30 secs?  How?
> > 
> > == TIA.
> > 
> > PS. power-cuts without `umount` are no problem for rPi's
> > SD nor USBstik.
> 
> However a power failure in the middle of a write commonly corrupts SD 
> cards and in some cases has been known to make them unusable.
> 
Apparently the rPi <lands safetly> as <the voltage is dropping>.
It's never failed during 5 cuts/day for 200 days.

> Most RTC chips have a small amount of battery backed scratchpad RAM.  
> Store timestamps for the start time + the current time in the scratchpad 
> and update at least every 30 seconds.   Due to the risk of a power 
> failure while updating the current time, you should use a checksum and 
> use two different locations, alternating between them.
> 
> The details of how to implement this in a Python script will depend on 
> the chip on your RTC module . . . .
> -- 
> Ian Malcolm. 
No Python. Just a bash script.
=======================================
From: William Unruh <unruh@invalid.ca>

]Power is cut? What does that mean? 
In the next paragraph, you've decided you know what it means.

> While `ogg123  SoundFie.ogg` is playing, could the play-time
> be updated every 30 secs?  How?
]How are you playing it, what is the player software?

`ogg123  SoundFie.ogg` means <SoundFie.ogg>,
is being played by "ogg123".

]Usually you can get a pretty good idea of the time of a power cut by
]looking at /var/log/messages and seeing when the last message
] was written before the cut.

 tail /var/log/messages  <--after start playing
 Oct 27 19:14:28 dog kernel: EXT4-fs: mounted filesystem sdc2 with ordered data mode
tail: cannot open `==' for reading: No such file or directory

 date  <-- during  playing
Mon Oct 27 19:15:35 SAST 2014

 tail /var/log/messages  <-- during  playing
Oct 27 19:14:28 dog kernel: EXT4-fs: mounted filesystem sdc2 with ordered data mode
tail: cannot open `==' for reading: No such file or directory

]POwer cuts are no problem for reading any medium. It is writing
]that is the problem.

Yes, but as the other respondent implies: the system could be writng
as part of it's <house-keeping>.
==========================================
Andrew Gabriel wrote:

]Pi's don't require much power, so you could keep the Pi running
]for a short time using stored power, and feed the real power loss
]signal into one of it's GPIO inputs, to be actioned by relevant
]software (such as logging the event and/or telling another system
]across the network), and finally trigger a clean shutdown before
]the stored power source runs out.

No, no extra hardware than the existing control, by switching-off
is allowed. Software could do:

N=ReadFileOfLatestTimePlayedSinceTrackStart
IF FileMarked=CutDuringPlay  // instead of during safePausePeriod
   THEN <Calculate restart Play N secs before Cut>
         ogg123 <M(N) secs FromBeginning>
   END      
   
]The risk is the flash memory microcode being interrupted in the
]middle of a critical operation, leaving some structure like the
]logical to physical block map corrupt, i.e. shuffling some of
]the blocks in the flash memory, although it may decide it's not
]going to play at all when next powered up.
]Enterprise class SSDs will protect themselves from this type of
]event, but cheap SD cards and USB sticks don't.

Sure. But it's survived 1'000 power cuts.
It must be designed to manage.

Joe Beanfish wrote:-
]You could start a background process at the same time as the player to
]save a timestamp every 5-10 seconds.

Exactly. I'm hoping someone will give me the code.

== TIA.

[toc] | [prev] | [next] | [standalone]


#12530

FromGordon Henderson <gordon+usenet@drogon.net>
Date2014-10-27 18:29 +0000
Message-ID<m2m2uk$8s6$2@dont-email.me>
In reply to#12529
In article <m2m1rf$6bh$1@dont-email.me>,  <not.socialnetwork@gmail.com> wrote:
>In article <XnsA3D2BB8ABDCA70xDEADBEEF@213.239.209.88>, Ian Malcolm <See.My.Sig.for.email@totally.invalid> wrote: 

>Sure. But it's survived 1'000 power cuts.
>It must be designed to manage.
>
>Joe Beanfish wrote:-
>]You could start a background process at the same time as the player to
>]save a timestamp every 5-10 seconds.
>
>Exactly. I'm hoping someone will give me the code.

You're probably getting away with it because for your application, all
you're doing is mostly reading the SD, so there's probably little to
no data needing to be written at power off time, and at boot time, an
automatic fsck will happen which (for the most part) will keep you good.

You could simply have:

#!/bin/bash

while true; do
  date >> /var/log/timefile ; sync
  sleep 5
done

and at boot time put something like:

  touch /var/log/timefile
  echo "--- we rebooted ---" >> /var/log/timefile

in e.g. /etc/rc.local

Will that work and not result in SD corruption? Hard to be sure. Give
it a go and let us know :-)

-Gordon

[toc] | [prev] | [next] | [standalone]


#12548

Fromnot.socialnetwork@gmail.com
Date2014-10-28 21:26 +0000
Message-ID<m2p1ms$9n9$1@dont-email.me>
In reply to#12530
In article <m2m2uk$8s6$2@dont-email.me>, Gordon Henderson <gordon+usenet@drogon.net> wrote: 

> In article <m2m1rf$6bh$1@dont-email.me>,  <not.socialnetwork@gmail.com> wrote:
> >In article <XnsA3D2BB8ABDCA70xDEADBEEF@213.239.209.88>, Ian Malcolm <See.My.Sig.for.email@totally.invalid> wrote: 
> 
> >Sure. But it's survived 1'000 power cuts.
> >It must be designed to manage.
> >
> >Joe Beanfish wrote:-
> >]You could start a background process at the same time as the player to
> >]save a timestamp every 5-10 seconds.
> >
> >Exactly. I'm hoping someone will give me the code.
> 
> You're probably getting away with it because for your application, all
> you're doing is mostly reading the SD, so there's probably little to
> no data needing to be written at power off time, and at boot time, an
> automatic fsck will happen which (for the most part) will keep you good.
> 
> You could simply have:
> 
> #!/bin/bash
> 
> while true; do
>   date >> /var/log/timefile ; sync
>   sleep 5
> done
> 
> and at boot time put something like:
> 
>   touch /var/log/timefile
>   echo "--- we rebooted ---" >> /var/log/timefile
> 
> in e.g. /etc/rc.local
> 
> Will that work and not result in SD corruption? Hard to be sure. Give
> it a go and let us know :-)
> 
> -Gordon =======

I've got the PlayControlScript on a stikUSB.
So that's where I'll put <timefile> for the next test.
It's difficult moving the data between 4 stages to get it to USEnet!
--
Probably the timer needs to be "BACKgrounded"?
So far I've not understood how the following trace shows what's
happening:-
Reboot, 21,33,43,53, <-- initial ?? followed by 10 secS
Reboot,20,32,42,52.
--
This was my code:--
System.Execute cat /mnt/stik/TTS4rPi/TTS.sh
...
oPlaySkip() # cutWhilePlaying=z
{
if [ -f $1.ogg ]; then
 mv $1.ogg  z$1.ogg # switch
 sync
 ogg123   z$1.ogg   # offerz
 mv z$1.ogg  $1.ogx # next
 sync
aplay Cut4Wax.wav   # offerx
  mv $1.ogx $1.ogg  # next = restored to g
sync

aplay SafeLand.wav  <_cut here=restore FileID for replay
fi
}
#-- MAIN---

oPlaySkip  Banting
oPlaySkip  MathBlog
oPlaySkip  BitC

touch /var/log/timeFile
echo "--we rebooted---" >> /var/log/timeFile

oPlaySkip  zj08cnt

while true; do
  date >> /var/log/timeFile ; sync
  sleep 10
done

oPlaySkip  functor
...
I cut-power while the 2nd file was playing,
which previously would have marked it as z*.ogg

==> Here's the 'newest stikFiles:
 ls -t /mnt/stik/TTS4rPi/*  
 /mnt/stik/TTS4rPi/TTS.sh
/mnt/stik/TTS4rPi/MathBlog.ogx <-cut after play
/mnt/stik/TTS4rPi/zBanting.ogg <-cut during play
/mnt/stik/TTS4rPi/zBitC.ogg <-cut during play
/mnt/stik/TTS4rPi/zplan9d.ogg <-cut previously
...
Of course rPi has no RTC, but each *.ogg that's
a TextToSpeech which is written to the stik,
is real-time-marked by the PC  - originally.

Apparently I must:
echo "reboot==" > ./TimeFile
at the begining of routine: oPlaySkip

Will the loop:
  date >> /var/log/timeFile ; sync ; sleep 10
stop, when oPlaySkip exits?
That would be good, since it's only needed
during oPlaySkip.
---------------------
No! The MULTIprocessor aspect is hidden/not-discussed;
almost fraudulently. It must become the starting point of
the design?

==TIA.


[toc] | [prev] | [next] | [standalone]


#12533

FromWilliam Unruh <unruh@invalid.ca>
Date2014-10-28 04:56 +0000
Message-ID<m2n7m1$ndo$1@dont-email.me>
In reply to#12529
On 2014-10-27, not.socialnetwork@gmail.com <not.socialnetwork@gmail.com> wrote:
> In article <XnsA3D2BB8ABDCA70xDEADBEEF@213.239.209.88>, Ian Malcolm <See.My.Sig.for.email@totally.invalid> wrote: 
>
>> not.socialnetwork@gmail.com wrote in news:m2jbi3$geq$1@dont-email.me:
>> 
>> > I need to capture the time-after-a-sound-file-starts-playing
>> > until the power is cut, with a resolution of 30 secs., over a
>> > period of 30 minutes.
>> > 
>> > While `ogg123  SoundFie.ogg` is playing, could the play-time
>> > be updated every 30 secs?  How?
>> > 
>> > == TIA.
>> > 
>> > PS. power-cuts without `umount` are no problem for rPi's
>> > SD nor USBstik.
>> 
>> However a power failure in the middle of a write commonly corrupts SD 
>> cards and in some cases has been known to make them unusable.
>> 
> Apparently the rPi <lands safetly> as <the voltage is dropping>.
> It's never failed during 5 cuts/day for 200 days.
>
>> Most RTC chips have a small amount of battery backed scratchpad RAM.  
>> Store timestamps for the start time + the current time in the scratchpad 
>> and update at least every 30 seconds.   Due to the risk of a power 
>> failure while updating the current time, you should use a checksum and 
>> use two different locations, alternating between them.
>> 
>> The details of how to implement this in a Python script will depend on 
>> the chip on your RTC module . . . .
>> -- 
>> Ian Malcolm. 
> No Python. Just a bash script.
>=======================================
> From: William Unruh <unruh@invalid.ca>
>
> ]Power is cut? What does that mean? 
> In the next paragraph, you've decided you know what it means.
>
>> While `ogg123  SoundFie.ogg` is playing, could the play-time
>> be updated every 30 secs?  How?
> ]How are you playing it, what is the player software?
>
> `ogg123  SoundFie.ogg` means <SoundFie.ogg>,
> is being played by "ogg123".
>
> ]Usually you can get a pretty good idea of the time of a power cut by
> ]looking at /var/log/messages and seeing when the last message
> ] was written before the cut.
>
>  tail /var/log/messages  <--after start playing
>  Oct 27 19:14:28 dog kernel: EXT4-fs: mounted filesystem sdc2 with ordered data mode
> tail: cannot open `==' for reading: No such file or directory
>
>  date  <-- during  playing
> Mon Oct 27 19:15:35 SAST 2014
>
>  tail /var/log/messages  <-- during  playing
> Oct 27 19:14:28 dog kernel: EXT4-fs: mounted filesystem sdc2 with ordered data mode
> tail: cannot open `==' for reading: No such file or directory
>
> ]POwer cuts are no problem for reading any medium. It is writing
> ]that is the problem.
>
> Yes, but as the other respondent implies: the system could be writng
> as part of it's <house-keeping>.
>==========================================
> Andrew Gabriel wrote:
>
> ]Pi's don't require much power, so you could keep the Pi running
> ]for a short time using stored power, and feed the real power loss
> ]signal into one of it's GPIO inputs, to be actioned by relevant
> ]software (such as logging the event and/or telling another system
> ]across the network), and finally trigger a clean shutdown before
> ]the stored power source runs out.
>
> No, no extra hardware than the existing control, by switching-off
> is allowed. Software could do:
>
> N=ReadFileOfLatestTimePlayedSinceTrackStart
> IF FileMarked=CutDuringPlay  // instead of during safePausePeriod
>    THEN <Calculate restart Play N secs before Cut>
>          ogg123 <M(N) secs FromBeginning>
>    END      
>    
> ]The risk is the flash memory microcode being interrupted in the
> ]middle of a critical operation, leaving some structure like the
> ]logical to physical block map corrupt, i.e. shuffling some of
> ]the blocks in the flash memory, although it may decide it's not
> ]going to play at all when next powered up.
> ]Enterprise class SSDs will protect themselves from this type of
> ]event, but cheap SD cards and USB sticks don't.
>
> Sure. But it's survived 1'000 power cuts.
> It must be designed to manage.
>
> Joe Beanfish wrote:-
> ]You could start a background process at the same time as the player to
> ]save a timestamp every 5-10 seconds.
>
> Exactly. I'm hoping someone will give me the code.

Make a file with the following content

#!/bin/bash
for ((i=0;i<10;i++))
do
while ps auxww |grep ogg123 |grep -v grep >/dev/null
do
date >/tmp/timestamp
sleep 10
done
sleep 10
done

and run it in the background when you start the ogg program.

>
>== TIA.
>

[toc] | [prev] | [next] | [standalone]


#12534

FromDom <domafp@blueyonder.co.uk>
Date2014-10-28 06:29 +0000
Message-ID<oJG3w.679289$KL.271645@fx19.am4>
In reply to#12533
On 28/10/14 04:56, William Unruh wrote:
>> Joe Beanfish wrote:-
>> ]You could start a background process at the same time as the player to
>> ]save a timestamp every 5-10 seconds.
>>
>> Exactly. I'm hoping someone will give me the code.
>
> Make a file with the following content
>
> #!/bin/bash
> for ((i=0;i<10;i++))
> do
> while ps auxww |grep ogg123 |grep -v grep >/dev/null
> do
> date >/tmp/timestamp
> sleep 10
> done
> sleep 10
> done
>
> and run it in the background when you start the ogg program.

Not a good idea to write to /tmp as that will get cleared when the Pi is 
next powered up (unless you change the default actions for /tmp).

Change "date >/tmp/timestamp" to "date >~/timestamp" to write to the 
home directory. Also add a "sync" line in after it to force flushing of 
the write buffers.

The very long "while ps auxww |grep ogg123 |grep -v grep >/dev/null" 
could be replaced by "while pidof ogg123 >/dev/null".

I'm not sure why you've got two loops there, the for () loop, and the 
while loop?

[toc] | [prev] | [next] | [standalone]


#12535

FromWilliam Unruh <unruh@invalid.ca>
Date2014-10-28 06:41 +0000
Message-ID<m2ndr4$5uu$1@dont-email.me>
In reply to#12534
On 2014-10-28, Dom <domafp@blueyonder.co.uk> wrote:
> On 28/10/14 04:56, William Unruh wrote:
>>> Joe Beanfish wrote:-
>>> ]You could start a background process at the same time as the player to
>>> ]save a timestamp every 5-10 seconds.
>>>
>>> Exactly. I'm hoping someone will give me the code.
>>
>> Make a file with the following content
>>
>> #!/bin/bash
>> for ((i=0;i<10;i++))
>> do
>> while ps auxww |grep ogg123 |grep -v grep >/dev/null
>> do
>> date >/tmp/timestamp
>> sleep 10
>> done
>> sleep 10
>> done
>>
>> and run it in the background when you start the ogg program.
>
> Not a good idea to write to /tmp as that will get cleared when the Pi is 
> next powered up (unless you change the default actions for /tmp).

True. Put it somewhere that is not cleared. (I do not have /tmp cleared
on reboot, but I agree that many do).

>
> Change "date >/tmp/timestamp" to "date >~/timestamp" to write to the 
> home directory. Also add a "sync" line in after it to force flushing of 
> the write buffers.
>
> The very long "while ps auxww |grep ogg123 |grep -v grep >/dev/null" 
> could be replaced by "while pidof ogg123 >/dev/null".

Fair enough. 

>
> I'm not sure why you've got two loops there, the for () loop, and the 
> while loop?

So that the script  will terminate when ogg123 actually finishes its
playing of the file. And so that it does not do it immedately since this
program might start before the ogg123 program gets going and terminate
before the ogg123 even gets started.



>

[toc] | [prev] | [next] | [standalone]


#12551

Fromnot.socialnetwork@gmail.com
Date2014-10-29 00:12 +0000
Message-ID<m2pbe5$br6$1@dont-email.me>
In reply to#12535
In article <m2ndr4$5uu$1@dont-email.me>, William Unruh <unruh@invalid.ca> wrote: 

> On 2014-10-28, Dom <domafp@blueyonder.co.uk> wrote:
> > On 28/10/14 04:56, William Unruh wrote:
> >>> Joe Beanfish wrote:-
---
>>> ]You could start a background process at the same time as the player to
>>> ]save a timestamp every 5-10 seconds.
>>>
>>> Exactly. I'm hoping someone will give me the code.
>>
>> Make a file with the following content
>>
>> #!/bin/bash
>> for ((i=0;i<10;i++))
>> do
>> while ps auxww |grep ogg123 |grep -v grep >/dev/null

# check for ogg123 & mask-out "grep"

>> do
>> date >/tmp/timestamp <- date >> ./Clok
>> sleep 10
>> done
>> sleep 10
>> done
>>
>> and run it in the background when you start the ogg program.

? HOW2 call it <in the background> FROM the StikPlay.sh which
autoruns at boot/power-on ?

>
> Not a good idea to write to /tmp as that will get cleared when the Pi is 
> next powered up (unless you change the default actions for /tmp).

]True. Put it somewhere that is not cleared. (I do not have /tmp cleared
]on reboot, but I agree that many do).

I'll write LOCAL ie. toTheStik = ./
There's no need to contaminate the 'system'.

> Change "date >/tmp/timestamp" to "date >~/timestamp" to write to the 
> home directory. Also add a "sync" line in after it to force flushing of 
> the write buffers.

The original design/tests failed because of such MULTIproccessor background
trickery, and needed "sync".
>
> The very long "while ps auxww |grep ogg123 |grep -v grep >/dev/null" 
> could be replaced by "while pidof ogg123 >/dev/null".

]Fair enough. 

There's no terminal to not-write-to, and reduced concepts are good.
Ie. <while it's still playing>, UpdateTimeStampEvery10Secs
>
> I'm not sure why you've got two loops there, the for () loop, and the 
> while loop?

]So that the script  will terminate when ogg123 actually finishes its
]playing of the file. And so that it does not do it immedately since this
]program might start before the ogg123 program gets going and terminate
]before the ogg123 even gets started.

I want all <subroutines> in 1 script, on the stik. So:
"So that the timer will terminate when the player finishes";
   would be controlled by <while pidof ogg123>.
   
"And so that the timer does not start & finish before the player starts".
 Yes, that's needed too, but it's not clear to me how it's achieved.

Can't we make a single minimalist test-script, which runs on the PC 
[instead of 'silently/hidden' on the rPi] , with the following structure:--

# Main block is just a sequence of `oplay  FILENAME`
oplay  FILENAME1
oplay  FILENAME2
oplay  FILENAME3

# single level-1 subroutine [omitting my other existing controls]
# can we set the "backgrounding" in this subroutine? & HOW?
oplay()
{   <proposed code>
}

== TIA.

[toc] | [prev] | [next] | [standalone]


#12496

FromWilliam Unruh <unruh@invalid.ca>
Date2014-10-26 19:23 +0000
Message-ID<m2jhnq$7b6$1@dont-email.me>
In reply to#12494
On 2014-10-26, not.socialnetwork@gmail.com <not.socialnetwork@gmail.com> wrote:
> I need to capture the time-after-a-sound-file-starts-playing
> until the power is cut, with a resolution of 30 secs., over a
> period of 30 minutes.

Power is cut? What does that mean? 
>
> While `ogg123  SoundFie.ogg` is playing, could the play-time
> be updated every 30 secs?  How?
How are you playing it, what is the player software?

Usually you can get a pretty good idea of the time of a power cut by
looking at /var/log/messages and seeind when the last message was written before the
cut.

>
>== TIA.
>
> PS. power-cuts without `umount` are no problem for rPi's
> SD nor USBstik.

POwer cuts are no problem for reading any medium. It is writing that is
the problem.

>

[toc] | [prev] | [next] | [standalone]


#12628

Fromspam-no-spam@Freeola.net.invalid (Windmill)
Date2014-11-04 13:19 +0000
Message-ID<nEInoz.37p@way.freeola.net>
In reply to#12496
William Unruh <unruh@invalid.ca> writes:

>On 2014-10-26, not.socialnetwork@gmail.com <not.socialnetwork@gmail.com> wrote:
>> I need to capture the time-after-a-sound-file-starts-playing
>> until the power is cut, with a resolution of 30 secs., over a
>> period of 30 minutes.

>Power is cut? What does that mean? 
>>
>> While `ogg123  SoundFie.ogg` is playing, could the play-time
>> be updated every 30 secs?  How?
>How are you playing it, what is the player software?

>Usually you can get a pretty good idea of the time of a power cut by
>looking at /var/log/messages and seeind when the last message was written before the
>cut.

Or if 1 minute intervals are acceptable you can edit the appropriate
place so that syslogd runs with option '-m 1' and then edit
/etc/syslogd.conf so that it includes the line

mark.*                          /var/log/tstamp

and then that tstamp file will contain things like 

Nov  4 11:44:04 Way -- MARK --
Nov  4 11:49:04 Way -- MARK --
Nov  4 11:54:04 Way -- MARK --

(which resulted from '-m 5')

This on a very old Linux system, from the days when you constructed
your own distribution from the available pieces.
So file locations and available options will surely have changed a
little in the interim.


-- 
Windmill, TiltNot@NoneHome.com       Use  t m i l l
J.R.R. Tolkien:-                            @ S c o t s h o m e . c o m
All that is gold does not glister / Not all who wander are lost

[toc] | [prev] | [next] | [standalone]


#12629

FromWilliam Unruh <unruh@invalid.ca>
Date2014-11-05 21:56 +0000
Message-ID<m3e6do$jh$1@dont-email.me>
In reply to#12628
On 2014-11-04, Windmill <spam-no-spam@Freeola.net.invalid> wrote:
> William Unruh <unruh@invalid.ca> writes:
>
>>On 2014-10-26, not.socialnetwork@gmail.com <not.socialnetwork@gmail.com> wrote:
>>> I need to capture the time-after-a-sound-file-starts-playing
>>> until the power is cut, with a resolution of 30 secs., over a
>>> period of 30 minutes.
>
>>Power is cut? What does that mean? 
>>>
>>> While `ogg123  SoundFie.ogg` is playing, could the play-time
>>> be updated every 30 secs?  How?
>>How are you playing it, what is the player software?
>
>>Usually you can get a pretty good idea of the time of a power cut by
>>looking at /var/log/messages and seeind when the last message was written before the
>>cut.
>
> Or if 1 minute intervals are acceptable you can edit the appropriate
> place so that syslogd runs with option '-m 1' and then edit
> /etc/syslogd.conf so that it includes the line

I have rsyslog but it has no -m option. Also the mark log facility
I have not seen before. When was it introduced into syslog? (there is no
explanation of what it is in the man page.)
I can also not find any explanation of the mark facility in syslogd
docs.


>
> mark.*                          /var/log/tstamp
>
> and then that tstamp file will contain things like 
>
> Nov  4 11:44:04 Way -- MARK --
> Nov  4 11:49:04 Way -- MARK --
> Nov  4 11:54:04 Way -- MARK --
>
> (which resulted from '-m 5')
>
> This on a very old Linux system, from the days when you constructed
> your own distribution from the available pieces.
> So file locations and available options will surely have changed a
> little in the interim.
>
>

[toc] | [prev] | [next] | [standalone]


#12640

FromJoe Beanfish <joebeanfish@nospam.duh>
Date2014-11-06 14:12 +0000
Message-ID<m3fvke$a6i$1@dont-email.me>
In reply to#12629
On Wed, 05 Nov 2014 21:56:08 +0000, William Unruh wrote:

> On 2014-11-04, Windmill <spam-no-spam@Freeola.net.invalid> wrote:
>> William Unruh <unruh@invalid.ca> writes:
>>>Usually you can get a pretty good idea of the time of a power cut by
>>>looking at /var/log/messages and seeind when the last message was
>>>written before the cut.
>>
>> Or if 1 minute intervals are acceptable you can edit the appropriate
>> place so that syslogd runs with option '-m 1' and then edit
>> /etc/syslogd.conf so that it includes the line
> 
> I have rsyslog but it has no -m option. Also the mark log facility I
> have not seen before. When was it introduced into syslog? (there is no
> explanation of what it is in the man page.)
> I can also not find any explanation of the mark facility in syslogd
> docs.

MARK has been a feature of syslog pretty much forever. e.g. my solaris
system from 1998 has it and I know it predates that.

[toc] | [prev] | [next] | [standalone]


#12642

Fromnba@users.sourceforge.net (Niels Baggesen)
Date2014-11-06 16:15 +0100
Message-ID<utfsib-0gu.ln1@nba-linux.sb.statsbiblioteket.dk>
In reply to#12629
William Unruh <unruh@invalid.ca> wrote:
> I have rsyslog but it has no -m option. Also the mark log facility
> I have not seen before. When was it introduced into syslog? (there is no
> explanation of what it is in the man page.)

In /etc/rsyslog.conf you will probably find

#$ModLoad immark  # provides --MARK-- message capability

uncomment that and add

$MarkMessagePeriod 600 # mark messages appear every 10 Minutes

/Niels

-- 
Niels Baggesen -- @home -- Ã…rhus -- Denmark -- niels@baggesen.net
The purpose of computing is insight, not numbers  --  R W Hamming

[toc] | [prev] | [next] | [standalone]


#12643

FromWilliam Unruh <unruh@invalid.ca>
Date2014-11-06 16:00 +0000
Message-ID<m3g5vn$4mg$2@dont-email.me>
In reply to#12642
On 2014-11-06, Niels Baggesen <nba@users.sourceforge.net> wrote:
> William Unruh <unruh@invalid.ca> wrote:
>> I have rsyslog but it has no -m option. Also the mark log facility
>> I have not seen before. When was it introduced into syslog? (there is no
>> explanation of what it is in the man page.)
>
> In /etc/rsyslog.conf you will probably find

/etc/rsyslog.d/00_common.conf
rsyslog.conf just has two lines, one to tell it to read the stuff in
rsyslog.d and the other to read syslog.conf. 
>
> #$ModLoad immark  # provides --MARK-- message capability
>
> uncomment that and add
>
> $MarkMessagePeriod 600 # mark messages appear every 10 Minutes

Thanks. Does it really have 1 second marking capability?
(Not that your logs would thank you.)

>
> /Niels
>

[toc] | [prev] | [next] | [standalone]


#12646

Fromspam-no-spam@Freeola.net.invalid (Windmill)
Date2014-11-06 20:37 +0000
Message-ID<nEMxAo.4tu@way.freeola.net>
In reply to#12629
William Unruh <unruh@invalid.ca> writes:

>On 2014-11-04, Windmill <spam-no-spam@Freeola.net.invalid> wrote:
>> William Unruh <unruh@invalid.ca> writes:
>>
>>>On 2014-10-26, not.socialnetwork@gmail.com <not.socialnetwork@gmail.com> wrote:
>>>> I need to capture the time-after-a-sound-file-starts-playing
>>>> until the power is cut, with a resolution of 30 secs., over a
>>>> period of 30 minutes.
>>
>>>Power is cut? What does that mean? 
>>>>
>>>> While `ogg123  SoundFie.ogg` is playing, could the play-time
>>>> be updated every 30 secs?  How?
>>>How are you playing it, what is the player software?
>>
>>>Usually you can get a pretty good idea of the time of a power cut by
>>>looking at /var/log/messages and seeind when the last message was written before the
>>>cut.
>>
>> Or if 1 minute intervals are acceptable you can edit the appropriate
>> place so that syslogd runs with option '-m 1' and then edit
>> /etc/syslogd.conf so that it includes the line

>I have rsyslog but it has no -m option. Also the mark log facility
>I have not seen before. When was it introduced into syslog? (there is no
>explanation of what it is in the man page.)
>I can also not find any explanation of the mark facility in syslogd
>docs.

I can't be sure where I got that version of syslogd; might have been a
Gnu or BSD version although a lot came from Debian. It was a long time
ago!

It's also possible that '-m' was a feature that had to be selected at
compile time (in those days you often had to compile things yourself).

But Google has references to '-m ', some as recent as 2013.
Maybe you need to use a syslogd with -r for remote logging, instead of
rsyslogd, to get the -m option?

Ah - after writing this I see that someone with up-to-date knowledge
has provided you with more relevant information, so the rest of this is
just of historical interest.

Saying "man syslogd" on that old (ancient!) system shows me this (note
it says sysklogd not syslogd; I've a vague recollection that there were
several flavours although this one's executable is in /bin as syslogd) :-


SYSKLOGD(8)        Linux System Administration        SYSKLOGD(8)

NAME
       sysklogd - Linux system logging utilities.

SYNOPSIS
       syslogd [ -d ] [ -f config file ] [ -h ] [ -l hostlist ] [
       -m interval ] [ -n ] [ -p socket ] [ -r ] [ -s  domainlist
       ] [ -v ]

DESCRIPTION
       Sysklogd  provides two system utilities which provide sup-
       port for system logging and kernel message trapping.  Sup-
       port of both internet and unix domain sockets enables this
       utility package to support both local and remote  logging.

       System  logging  is  provided  by  a version of syslogd(8)
       derived from the stock BSD sources.   Support  for  kernel
       logging  is  provided by the klogd(8) utility which allows
       kernel logging to be  conducted  in  either  a  standalone
       fashion or as a client of syslogd.

       Syslogd  provides  a kind of logging that many modern pro-
       grams use. Every logged message contains at least  a  time
       and  a hostname field, normally a program name field, too,
       but that depends on how trusty the logging program is.

       While the syslogd sources have  been  heavily  modified  a
       couple of notes are in order.  First of all there has been
       a systematic attempt to insure that  syslogd  follows  its
       default, standard BSD behavior.  The second important con-
       cept to note is that this  version  of  syslogd  interacts
       transparently  with  the  version  of  syslog found in the
       standard libraries.  If a binary linked  to  the  standard
       shared libraries fails to function correctly we would like
       an example of the anomalous behavior.

       The main configuration file /etc/syslog.conf or an  alter-
       native file, given with the -f option, is read at startup.
       Any lines that begin with the hash mark (``#'') and  empty
       lines  are  ignored. If an error occurs during parsing the
       whole line is ignored.

OPTIONS
       -d     Turns on debug mode. Using this the daemon will not
              proceed  a fork(2) to set itself in the background,
              but opposite to that stay  in  the  foreground  and
              write  much  debug  information on the current tty.
              See the DEBUGGING section for more information.

       -f config file
              Specify an alternative configuration  file  instead
              of /etc/syslog.conf, which is the default.

Version 1.3              13 December 1995                       1

SYSKLOGD(8)        Linux System Administration        SYSKLOGD(8)

       -h     By  default  syslogd  will  not forward messages it
              receives from remote hosts.  Specifying this switch
              on  the  command  line will cause the log daemon to
              forward any remote messages it receives to forward-
              ing hosts which have been defined.

       -l hostlist
              Specify  a hostname that should be logged only with
              its simple hostname  and  not  the  fqdn.  Multiple
              hosts may be specified using the colon (``:'') sep-
              arator.

       -m interval
              The syslogd logs a mark  timestamp  regularly.  The
              default interval between two -- MARK -- lines is 20
              minutes. This can be changed with this option.

       -n     Avoid auto-backgrounding. This is needed especially
              if   the  syslogd  



-- 
Windmill, TiltNot@NoneHome.com       Use  t m i l l
J.R.R. Tolkien:-                            @ S c o t s h o m e . c o m
All that is gold does not glister / Not all who wander are lost

[toc] | [prev] | [next] | [standalone]


#12641

FromJoe Beanfish <joebeanfish@nospam.duh>
Date2014-11-06 14:13 +0000
Message-ID<m3fvn4$a6i$2@dont-email.me>
In reply to#12628
On Tue, 04 Nov 2014 13:19:47 +0000, Windmill wrote:

> William Unruh <unruh@invalid.ca> writes:
> 
>>On 2014-10-26, not.socialnetwork@gmail.com <not.socialnetwork@gmail.com>
>>wrote:
>>> I need to capture the time-after-a-sound-file-starts-playing until the
>>> power is cut, with a resolution of 30 secs., over a period of 30
>>> minutes.
> 
>>Power is cut? What does that mean?
>>>
>>> While `ogg123  SoundFie.ogg` is playing, could the play-time be
>>> updated every 30 secs?  How?
>>How are you playing it, what is the player software?
> 
>>Usually you can get a pretty good idea of the time of a power cut by
>>looking at /var/log/messages and seeind when the last message was
>>written before the cut.
> 
> Or if 1 minute intervals are acceptable you can edit the appropriate
> place so that syslogd runs with option '-m 1' and then edit
> /etc/syslogd.conf so that it includes the line
> 
> mark.*                          /var/log/tstamp
> 
> and then that tstamp file will contain things like
> 
> Nov  4 11:44:04 Way -- MARK --
> Nov  4 11:49:04 Way -- MARK --
> Nov  4 11:54:04 Way -- MARK --
> 
> (which resulted from '-m 5')
> 
> This on a very old Linux system, from the days when you constructed your
> own distribution from the available pieces.
> So file locations and available options will surely have changed a
> little in the interim.

This is wandering way off topic. The OP wanted to know how far into
a track he had listened before power off. Presumably so he could
pickup where he left off.

[toc] | [prev] | [next] | [standalone]


#12497

Fromandrew@cucumber.demon.co.uk (Andrew Gabriel)
Date2014-10-26 20:28 +0000
Message-ID<m2jlhb$n3c$1@dont-email.me>
In reply to#12494
In article <m2jbi3$geq$1@dont-email.me>,
	not.socialnetwork@gmail.com writes:
> I need to capture the time-after-a-sound-file-starts-playing
> until the power is cut, with a resolution of 30 secs., over a
> period of 30 minutes.
> 
> While `ogg123  SoundFie.ogg` is playing, could the play-time
> be updated every 30 secs?  How?

Pi's don't require much power, so you could keep the Pi running
for a short time using stored power, and feed the real power loss
signal into one of it's GPIO inputs, to be actioned by relevant
software (such as logging the event and/or telling another system
across the network), and finally trigger a clean shutdown before
the stored power source runs out.

> == TIA.
> 
> PS. power-cuts without `umount` are no problem for rPi's
> SD nor USBstik.

The risk is the flash memory microcode being interrupted in the
middle of a critical operation, leaving some structure like the
logical to physical block map corrupt, i.e. shuffling some of
the blocks in the flash memory, although it may decide it's not
going to play at all when next powered up.
Enterprise class SSDs will protect themselves from this type of
event, but cheap SD cards and USB sticks don't.

-- 
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]

[toc] | [prev] | [next] | [standalone]


#12523

FromJoe Beanfish <joebeanfish@nospam.duh>
Date2014-10-27 13:17 +0000
Message-ID<m2lgle$tqe$1@dont-email.me>
In reply to#12494
On Sun, 26 Oct 2014 17:38:12 +0000, not.socialnetwork wrote:

> I need to capture the time-after-a-sound-file-starts-playing until the
> power is cut, with a resolution of 30 secs., over a period of 30
> minutes.
> 
> While `ogg123  SoundFie.ogg` is playing, could the play-time be updated
> every 30 secs?  How?
> 
> == TIA.
> 
> PS. power-cuts without `umount` are no problem for rPi's SD nor USBstik.

You could start a background process at the same time as the player to
save a timestamp every 5-10 seconds.

[toc] | [prev] | [next] | [standalone]


#12543

FromJean-David Beyer <jeandavid8@verizon.net>
Date2014-10-28 13:43 -0400
Message-ID<m2okk2019qe@news1.newsguy.com>
In reply to#12494
On 10/26/2014 01:38 PM, not.socialnetwork@gmail.com wrote:
> I need to capture the time-after-a-sound-file-starts-playing
> until the power is cut, with a resolution of 30 secs., over a
> period of 30 minutes.
> 
> While `ogg123  SoundFie.ogg` is playing, could the play-time
> be updated every 30 secs?  How?
> 
> == TIA.
> 
> PS. power-cuts without `umount` are no problem for rPi's
> SD nor USBstik.
> 

I have an APC SMART-2200 UPS on my machine and I run apcupsd on it. So
when the power fails, it logs that (to the second) and when it comes
back, it logs that too after the reboot is complete.

-- 
  .~.  Jean-David Beyer          Registered Linux User 85642.
  /V\  PGP-Key:166D840A 0C610C8B Registered Machine  1935521.
 /( )\ Shrewsbury, New Jersey    http://linuxcounter.net
 ^^-^^ 13:40:01 up 37 days, 23:32, 2 users, load average: 5.07, 4.54, 4.48

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.os.linux.misc


csiph-web