In one of my bash-scripts where I use a file to write the current system time, I noticed that the correct time only gets written to the file every second time the script runs.
I did a second script to test it, and it shows the same behavior.
The script:
#!/bin/bash
NOW=$(date +"%F_%H:%M:%S")
wtimestamp="/home/pazau/logfiles/overviewer-timestamp"
timestamp=$(<$wtimestamp)
echo $NOW > $wtimestamp
echo $timestamp
The system is Ubuntu 14.04 x64, and a Raspberry Pi model B with raspbian. The behavior is the same on both systems.
Anything i'm missing?
$NOW
instead of the previous contents of the file:$timestamp
.