lost file when power loss

We have system where power can suddenly disappear.
At the beginning of sysinit we do a

chkfsys -Pqrs /

and it seems mostly to work.

But sometimes our start script, (invoked from sysinit),
and named

/home/sys/start

mysteriously disappears together with a sub directory called

/home/sys/tmp

The ‘tmp’ directory is used for log files, and is created if it doesn’t
exist.
Any log files are then cycled.

I attach a code snippet showing the code:

Create log directory if not exist

if [ ! -d $SYS_TMPDIR ]; then
/bin/mkdir $SYS_TMPDIR
fi

Cycle log files

for file in $MSG_LOG $ERROR_LOG; do
let i=$NO_LOGFILES
while [ $i -gt 1 ]; do
let i=$i-1
let j=$i+1
[ -f ${file}.$i ] && mv ${file}.$i ${file}.$j
done
[ -f ${file} ] && mv ${file} ${file}.1
done

The NO_LOGFILES can be about 250.

I suspect that if power is lost when cycling the log files,
the QNX file system can be damaged. The log file cycling
is at system startup, and power loss could very well happen at this
time.

My question is: Can I prevent this from happen ?
My concern is the start script, loss of log file directory isn’t that
critical.

Any comments are welcome

best regards


Per Åkesson
Carmenta AB
SWEDEN

Best way is to use a UPS. What options are used when you start Fsys. I’d
make sure
you are not using the “-a” option as this increases chance of file
corruption on power
loss. If you are using the “-d” option it is no longer needed if you are
not using, or
are removing the “-a” option. Good luck.

Ivan Bannon


“Per Akesson” <Per.Akesson@carmenta.se> wrote in message
news:3BA98BC6.E8D6ACC4@carmenta.se
We have system where power can suddenly disappear.
At the beginning of sysinit we do a

chkfsys -Pqrs /

and it seems mostly to work.

But sometimes our start script, (invoked from sysinit),
and named

/home/sys/start

mysteriously disappears together with a sub directory called

/home/sys/tmp

The ‘tmp’ directory is used for log files, and is created if it doesn’t
exist.
Any log files are then cycled.

I attach a code snippet showing the code:

Create log directory if not exist

if [ ! -d $SYS_TMPDIR ]; then
/bin/mkdir $SYS_TMPDIR
fi

Cycle log files

for file in $MSG_LOG $ERROR_LOG; do
let i=$NO_LOGFILES
while [ $i -gt 1 ]; do
let i=$i-1
let j=$i+1
[ -f ${file}.$i ] && mv ${file}.$i ${file}.$j
done
[ -f ${file} ] && mv ${file} ${file}.1
done

The NO_LOGFILES can be about 250.

I suspect that if power is lost when cycling the log files,
the QNX file system can be damaged. The log file cycling
is at system startup, and power loss could very well happen at this
time.

My question is: Can I prevent this from happen ?
My concern is the start script, loss of log file directory isn’t that
critical.

Any comments are welcome

best regards


Per Åkesson
Carmenta AB
SWEDEN