Hopefully, someone has already seen this and knows whats up.
Simple script myscript.sh:
#!/bin/sh
i=1
date
while [ 1 ]; do
echo "Count - ${i}"
cat /etc/system
i=`expr ${i} + 1`
sleep 5
done
Run it as:
nohup sh myscript.sh > /tmp/myscript.log &
Let it run for a while. Then run:
grep Count /tmp/myscript.log | wc -l
ls -l /tmp/myscript.log
cat /dev/null /tmp/myscript.log
ls -l /tmp/myscript.log
ls -l /tmp/myscript.log
ls -l /tmp/myscript.log
grep Count /tmp/myscript.log | wc -l
The file size info on my system (Solaris 8) for the /tmp/myscript.log
is zero at first and then goes right back to where it was but a bit
more when the next iteration of the cat command output /etc/system.
Also, the first grep..wc -l command shows how many times the script
has basically looped. The second grep will show only a couple. This
shows that the inode is saying the file contains everything is always
did but the grep command is saying it only contains up to some of
point a buffer - maybe the output file descriptor buffer? I'm
guessing I'm not a programmer
If you change the ">" to a ">>" with your nohup , it works as
expected. The file is zeroed out and the inode info shows it growing
as you would expect it to.
What's the differences between ">" and ">>" that makes this happen?
Running the script with ksh does the same thing.
Looks like a bug to me.
--
........................................................
......... ..- -. .. -..- .-. ..- .-.. . ... ............
.-- .. -. -... .-.. --- .-- ... -.. .-. --- --- .-.. ...
Sean O'Neill