HOW2 capture time of power-failure?

You've got that backward. Multics was quite successful in its day but, being quite a large system, was too expensive to have many installations. The project started in 1964, there were 80 Multics installations and the last one was decomissioned in 2000. I don't call that failure. The ideas behind it had a big influence on many of the later OSes.

See:

formatting link
for details.

Plan 9 is arguably less successful than Unix: I've used several Unix flavours but never seen a Plan 9 system. In any case both have been more or less totally eclipsed by Linux.

========== You may find the following script a little easier to follow when it runs that the original. I've added a parameter to switch between killing the background task:

tscript

and waiting for it to end:

tscript wait

I've also changed the echoed output to make the source of the various messages a bit clearer:

========================start of tscript========================= #!/bin/sh echo "Foreground: pid $$ starting" (echo " Background: started";sleep 5;echo " Background: finished") & bgpid=$! echo "Foreground: background with pid $bgpid is running" sleep 1

# wait around for background process to finish before quitting if [ "$1" == 'wait' ] then echo "Foreground: waiting for background pid $bgpid to end" wait $bgpid else echo "Foreground: stopping background process before quitting" echo "Foreground: killing background pid $bgpid" kill -9 $bgpid fi echo "Foreground: pid $$ finished" ======================== end of tscript =========================

The script has 18 lines: if you see fewer, this will be due to some lines having been combined by your newsreader, so descramble this version before trying to run it.

--
martin@   | Martin Gregorie 
gregorie. | Essex, UK 
org       |
Reply to
Martin Gregorie
Loading thread data ...

Of course they degenerate, he's been trolling for years. This thread is typical. He asks a question and replies when there are enough people trying to help him with something that doesn't quite make sense and he gets more replies.

Lather, rinse, repeat.

Reply to
mm0fmf

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
Reply to
Windmill

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.

Reply to
William Unruh

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.

Reply to
Joe Beanfish

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.

Reply to
Joe Beanfish

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

--

The purpose of computing is insight, not numbers  --  R W Hamming
Reply to
Niels Baggesen

/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.

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

Reply to
William Unruh

========================start of tscript========================= #!/bin/sh echo "Foreground: pid $$ starting" (echo " Background: started";sleep 5;echo " Background: finished") & bgpid=$! echo "Foreground: background with pid $bgpid is running" sleep 1

# wait around for background process to finish before quitting if [ "$1" == 'wait' ] then echo "Foreground: waiting for background pid $bgpid to end" wait $bgpid else echo "Foreground: stopping background process before quitting" echo "Foreground: killing background pid $bgpid" kill -9 $bgpid fi echo "Foreground: pid $$ finished" ======================== end of tscript ====================

OK thanks, but I don't see your "top" structure. Is there ONE foreground, and potentially multiple background PIDs, hence "the latest background"? For my application, I want the player to be the boss - to start the timer. For 'civilised' code, the player would also switch-off the timer, which would have recorded to LastTimeStamp. For my application: cutting the power automatically syncronises the and last-TimeStamp.

Is this Top-structure valid? StartPlay (date > TimeStamp; sleep 5) &

Reply to
not.socialnetwork

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
Reply to
Windmill

Everything in the script is the foreground process except for line 3,

(....)&

which is the background process that is controlled by the foreground process.

Since you don't seem to have the technical background to understand the what we've been saying about interprocess communication, here's some advice: get hold of "UNIX Systems Programming for SVR4" and work your way through Chapter 11, 'Processes', compiling and running the example code and experimenting with it until you understand what's going on. Depending on your experience you may find that you need to work through several other chapters too.

If you're serious about your project, you'll do the reading and should be able to complete it without further help from here.

--
martin@   | Martin Gregorie 
gregorie. | Essex, UK 
org       |
Reply to
Martin Gregorie

Correct. Something like this perhaps:

#!/bin/sh while :;do date > TimeStamp;sleep 5;done & bgpid=$! StartPlay kill $bgpid rm -f TimeStamp

Or, you could flip it on it's head and run player in background with stamper in fore.

#!/bin/sh StartPlay & bgpid=$! # run forever until StartPlay finishes (process no longer exists) while kill -s 0 $bgpid 2>/dev/null;do date >TimeStamp done rm -f TimeStamp

Reply to
Joe Beanfish

That seems to test GOOD on the live-PC. I'll test by power-cut on rPi later. JB.sh == #!/bin/sh echo "IF State=Skip THEN PlayFrom(TimeStamp)" echo -n "Previous TimeStamp="; cat TimeStamp

while :;do date > TimeStamp;sleep 5;done & bgpid=$! echo StartPlay;sleep 25 echo StillPlaying;sleep 25 echo "After Play stop: kill BakPID" kill $bgpid echo "TimeStamp is used by next Start/PowerUp:" echo -n "Currently=" cat TimeStamp

exit 0

log of 2 consecutive runs == IF State=Skip THEN PlayFrom(TimeStamp) Previous TimeStamp=Sat Nov 8 05:08:19 SAST 2014 StartPlay StillPlaying After Play stop: kill BakPID TimeStamp is used by next Start/PowerUp: Currently=Sat Nov 8 05:12:19 SAST 2014 ./JB.sh: line 13: 20334 Terminated while :; do date >TimeStamp; sleep 5; done === IF State=Skip THEN PlayFrom(TimeStamp) Previous TimeStamp=Sat Nov 8 05:12:19 SAST 2014 StartPlay StillPlaying After Play stop: kill BakPID TimeStamp is used by next Start/PowerUp: Currently=Sat Nov 8 05:13:57 SAST 2014 ./JB.sh: line 13: 20360 Terminated while :; do date >TimeStamp; sleep 5; done ===

Thanks, I'll report the rPi live-test-results.

Reply to
not.socialnetwork

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.