I am trying to prepend log entries with a timestamp, but the generated timestamps do not seem to change over time:
#!/bin/sh NOW=$(date +"%Y-%m-%d %H:%M:%S") echo "$NOW Logging something" sleep 2 echo "$NOW Logging something else"
Output for is:
2012-03-02 12:32:49 Logging something 2012-03-02 12:32:49 Logging something else
Does anybody know what I am doing wrong?