I want to add a timestamp to server events and store the result in a log.
My first idea was :
( ./runServer.sh ) | sed "s/.*/`date +%s` & /" | xargs -0 >Server.log 2>&1 &
But it seems sed never reevaluates the date, so all events get the same timestamp.
Now I'm trying to get around that using environment variable but I can't find a proper way to do it.
I have this obviously wrong line below :
( ./runServer.sh ) | xargs -0 'export mydate=`date +%s` ; sed "s/.*/$mydate & /"' >Server.log 2>&1 &
Any hints? Thanks.