Timestamp in Logfile SOLVED

More
04 Mar 2019 11:53 #127685 by MaHa
Timestamp in Logfile was created by MaHa
I log results from toolset, offsets and probing. Occasionally need the initial value again.
The below m function makes a timestamp in the logfile, unfortunately always after the log entry.
If M100 is before LOGAPPEND or after (LOGCLOSE) makes no difference.
If someone has an idea, how to place the timestamp before the log entry.
Thanks

#!/bin/bash
file=/LOG_100.NGC
echo "* prob webcent: " "$(date "+%A %d.%B %Y %T") *" >> $file
echo "" >> $file
echo "*********************************************************************" >> $file

Please Log in or Create an account to join the conversation.

More
04 Mar 2019 13:33 #127691 by pl7i92
Replied by pl7i92 on topic Timestamp in Logfile
hi you may like it that way
!/bin/bash

# Define a timestamp function
timestamp() {
  date +"%T"
}

# do something...
timestamp # print timestamp
# do something else...
timestamp # print another timestamp
# continue...

Please Log in or Create an account to join the conversation.

More
04 Mar 2019 20:25 - 05 Mar 2019 22:38 #127727 by MaHa
Replied by MaHa on topic Timestamp in Logfile
.
Last edit: 05 Mar 2019 22:38 by MaHa.

Please Log in or Create an account to join the conversation.

More
07 Mar 2019 22:53 - 14 Mar 2019 03:12 #128037 by MaHa
Replied by MaHa on topic Timestamp in Logfile SOLVED
Thanks there was not much input to this problem, so I realized this in a way, working better as desired.
The newest entry is at the top of the file, so don`t have to scroll for the new entrys.
LOG_TEST.NGC containing the LOGs. LOG1 and LOG2 are temporary and can be deleted.

UPDATED:

The LOG routine:

(LOGOPEN,/home/tesla/NcFiles/LOGs/.LOG1)
(LOG,)
(LOG,* WK_WEBCENT Y = 277.258 ** D_WEBCENT Y = 358.119 *)
(LOGCLOSE)
M66 E0 L0
M150 P100
M66 E0 L0


The to make executable M150:


#!/bin/bash
# .LOG1 und .LOG2 not visible
file=/home/tesla/NcFiles/LOGs/.LOG1
file=/home/tesla/NcFiles/LOGs/.LOG2
case $1 in
100.000000)
file=/home/tesla/NcFiles/LOGs/LOG_100.NGC
meas="* Stegmittelpunkt ermittelt am: "
;;
101.000000)
file=/home/tesla/NcFiles/LOGs/LOG_101.NGC
meas="* Bohrungsmittelpunkt ermittelt am: "
;;
102.000000)
file=/home/tesla/NcFiles/LOGs/LOG_102.NGC
meas="* Bohrungsdurchmesser ermittelt am: "
;;
esac
timestamp="$(date "+%A %d.%B %Y %T")"
cat $file > $file2
echo "$meas $timestamp *" > $file
cat $file1 >> $file
echo ";***********************************************************************" >> $file
cat $file2 >> $file
exit 0


Updated this post with recent changes, the extended version is running on my machine.
When implementing to my probing routines, some changes required. Now all process have their own LOG file.
Otherwise was a mess. The temporary LOG1 and LOG2 made not visible.
And the most important change, queue buster for solid results.
Last edit: 14 Mar 2019 03:12 by MaHa. Reason: Replaced with final version
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

Time to create page: 0.110 seconds
Powered by Kunena Forum