Logging bootscript output

Bruce Dubbs bruce.dubbs at gmail.com
Wed Feb 21 19:04:52 PST 2007


Bruce Dubbs wrote:

> #!/bin/bash
> 
> i=0
> 
> while read line; do
>   if [ $line == 'fini' ]; then break; fi
> 
>   time=$(date +%T)
>   l[$i]="$time $line"
>   i=$(($i+1))
> done
> 
> j=0
> 
> while [ $j -lt $i ]; do
>   echo ${l[$j]}      # >> /var/log/bootlog
>   j=$(($j+1))
> done

Changing to the following works.  I did:

./boot.sh &
echo something > /dev/bootlog
echo something else > /dev/bootlog
echo fini > /dev/bootlog

and get the expected output.

20:59:29 something
20:59:35 something else

I'll also note that if we do this, then it will help document where time
is used during the boot process.

 -- Bruce

#!/bin/bash

i=0
while /bin/true; do
  exec 3</dev/bootlog
  while read -u 3 line; do
    if [ "x$line" == 'xfini' ]; then break; fi

    time=$(date +%T)
    l[$i]="$time $line"
    i=$(($i+1))
  done
  if [ "x$line" == 'xfini' ]; then break; fi
done

j=0

while [ $j -lt $i ]; do
  echo ${l[$j]}
  j=$(($j+1))
done




More information about the lfs-dev mailing list