Need to generate a record that yields start time & end time
Need to generate a record that yields start time & end time
I am new to CLI Linux appl.
I want to be able to record the start time of a script start and its end time on a single record.
Can anyone suggest something?
Thanks in advance
I want to be able to record the start time of a script start and its end time on a single record.
Can anyone suggest something?
Thanks in advance
Thanks DPUP5520. I need to record a start time, issue a command line (CL) command then capture the end time. It would be nice to see elapse time in the same record. This doesn't have to be fancy or in a GUI. Essentially, it would produce a record of start, I would execute my CL command (say cp "file1 file2") and record and post the completion time on exit. Kinda like this:DPUP5520 wrote:uh you mean like a stopwatch? pclock has one of those.
Code: Select all
# record_time_script
....something capture start time
cp file1 file2
....something reports start-time and current time (and maybe elasped time)
exit
im sure some one with more knowledge will chime in but in the mean time what about some thing like:
echo start / end time when script is run from terminal.
or to see how long a script takes to run use command in terminal:
time myscript
Code: Select all
#!/bin/sh
time_start=`date +%R:%S`
mtpaint &
time_end=`date +%R:%S`
echo -e ":Started: \e[1;31m$time_start\e[0m :Ended: \e[1;31m$time_end\e[0m"
or to see how long a script takes to run use command in terminal:
time myscript
Dear Stu and dcmartin,
What about something like this:
The results could be piped to a file, and this little routine could also be guified.
With kind regards,
vovchik
What about something like this:
Code: Select all
#!/bin/sh
# provide app name on command line
myprog="$@"
mydate=`date +%y-%m-%d`
before=`date +%s`
time_start=`date +%R:%S`
# application launch
"$myprog"
after=`date +%s`
time_end=`date +%R:%S`
elapsed_seconds=`expr $after - $before`
# results
echo "Date : $mydate"
echo "Application : $myprog"
echo "Start time : $time_start"
echo "End time : $time_end"
echo "Elapsed time : $elapsed_seconds seconds"
With kind regards,
vovchik
gcmartin,
If I'm not mistaken this is for your ip status.
Beware running the script too often to check your IP. What you are doing is making a call to someones website, this then runs its script and returns your IP.
However, they won't be too happy if you poll it often, you will be using their bandwidth. Best you could achieve is an approximation.
A better solution may be to see if your router can log event changes. Mine can I'm sure. The log can be parsed for the info you require.
If I'm not mistaken this is for your ip status.
Beware running the script too often to check your IP. What you are doing is making a call to someones website, this then runs its script and returns your IP.
However, they won't be too happy if you poll it often, you will be using their bandwidth. Best you could achieve is an approximation.
A better solution may be to see if your router can log event changes. Mine can I'm sure. The log can be parsed for the info you require.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)
Hi vovchik,vovchik wrote:Dear Stu and dcmartin,
What about something like this:
The results could be piped to a file, and this little routine could also be guified.
With kind regards,
vovchik
i have added a yad GUI and a some colour to the terminal output on your script
Code: Select all
#!/bin/sh
# provide app name on command line
red="\e[1;31m"
co="\e[0m"
myprog="$@"
mydate=`date +%y-%m-%d`
before=`date +%s`
time_start=`date +%R:%S`
# application launch
"$myprog"
after=`date +%s`
time_end=`date +%R:%S`
elapsed_seconds=`expr $after - $before`
# results
echo -e "Date : "$red"$mydate"$co""
echo -e "Application : "$red"$myprog"$co""
echo -e "Start time : "$red"$time_start"$co""
echo -e "End time : "$red"$time_end"$co""
echo -e "Elapsed time : "$red"$elapsed_seconds seconds"$co""
yad --title="Time Results" --text="
Date : <b>$mydate</b> \n
Application : <b>$myprog</b> \n
Start time : <b>$time_start</b> \n
End time : <b>$time_end</b> \n
Elapsed time : <b>$elapsed_seconds seconds</b> "
thanks.
Thanks @Tasmod, but that is not the mission of the request for help.tasmod wrote:gcmartin, If I'm not mistaken this is for your ip status.
...
I am looking to get a tool/method of measuring behavior. This contributions are of "Extreme Value", to me, as its use intends to remove some subjectivity from much of what I'm reporting to this community.
This community is maturing very fast. It also expanding exponentially; obvious over the achievements of the last year. Much of what the community has done has been on emotional guidance. I now see more and more movement to expand emotional into the realm of "objective emotion" as it continues to grow and expand. This expansion is generating a "Public Open Source Software Product", beyond the likes of anything the planet has seen (although, its not defining itself as that yet).
But, you are right about your observation of postings I've made about the network tools that DPUP5520 has made available to the community. Those are positive contributions, but his work is designed to help us on the LAN level versus WAN. I currently have not seen any work, by him, at the WAN level which you refer. Appears that his tools are for local LAN administration use/needs.
So, I looking at some ways to improve what we report, usefully. And, I want to investigate some simple ways of doing this that is easily understood when seen within the community.
Thanks @STU90 and @Vovchik. The 2 of you have "hit the nail on the head". What a creative effort in the blink of an eye! One of you should make this a pet. I see it sitting along side Hardinfo on the Menu. This is very thoughtful, does not use CPU while command is running, and reports/records as needed for evaluation. Really, really outstanding effort!
This may become wide-spread in use and reporting either as a base for reporting or simply as eye-check reference.
What should it be named?
app timer
Dear stu and dcmartin,
@stu: great.
@both: I also think that an echo >> /root/.appstats/appstats.log might be a nice enhancement, using either "|" or "," as a delimiter to a single-line multi-field record, which would contain the app name (basename $myprog, start time, end time and elapsed time). And the gui could have "Log" and "View" buttons (sorting either by date or by app name). Just an idea. I have no idea what this little utility should be called. What about "plogger"?
With kind regards,
vovchik
@stu: great.
@both: I also think that an echo >> /root/.appstats/appstats.log might be a nice enhancement, using either "|" or "," as a delimiter to a single-line multi-field record, which would contain the app name (basename $myprog, start time, end time and elapsed time). And the gui could have "Log" and "View" buttons (sorting either by date or by app name). Just an idea. I have no idea what this little utility should be called. What about "plogger"?
With kind regards,
vovchik
Re: app timer
Thanks. @Vovchik. I like the idea. Though, the log doesn't have to be hidden. Maybe placed invovchik wrote:Dear stu and dcmartin,
@stu: great.
@both: I also think that an echo >> /root/.appstats/appstats.log might be a nice enhancement, using either "|" or "," as a delimiter to a single-line multi-field record, which would contain the app name (basename $myprog, start time, end time and elapsed time). And the gui could have "Log" and "View" buttons (sorting either by date or by app name). Just an idea. I have no idea what this little utility should be called. What about "plogger"?
With kind regards,
vovchik
I initially called it "measureit". Your script works for "measureit hardinfo". BUT does not work for either of the following.
Thanks in advance for guidance.sh-4.1# measure-it hardinfo
Date : 11-06-20
Application : hardinfo
Start time : 10:49:50
End time : 10:50:01
Elapsed time : 11 seconds
sh-4.1# measure-it hardinfo -r
/root/my-applications/bin/measure-it: line 8: hardinfo -r: command not found
Date : 11-06-20
Application : hardinfo -r
Start time : 10:50:19
End time : 10:50:19
Elapsed time : 0 seconds
sh-4.1# measure-it "hardinfo -r"
/root/my-applications/bin/measure-it: line 8: hardinfo -r: command not found
Date : 11-06-20
Application : hardinfo -r
Start time : 10:54:46
End time : 10:54:46
Elapsed time : 0 seconds
sh-4.1#
Dear gcmartin,
If you want the parameters passed, just remove the double quotes surrounding "$myprog" as a quick hack. Eventually, we should tally the arguments, run $1 and save that to the log as a separate entry separate from the complete argument list ["$@"]. The argument count is given by "$#". I think this also might be a case for using "getopts".
With kind regards,
vovchik
If you want the parameters passed, just remove the double quotes surrounding "$myprog" as a quick hack. Eventually, we should tally the arguments, run $1 and save that to the log as a separate entry separate from the complete argument list ["$@"]. The argument count is given by "$#". I think this also might be a case for using "getopts".
With kind regards,
vovchik
Works
Thanks @Vovchikvovchik wrote: ... just remove the double quotes surrounding "$myprog" ... Eventually, we should ... .
Code: Select all
sh-4.1# measure-it hardinfo -r
Computer
Summary
Operating System
Kernel Modules
Boots
Languages
Filesystems
Display
Environment Variables
Users
Devices
Processor
Memory
PCI Devices
USB Devices
Printers
Battery
sh: -c: option requires an argument
Sensors
Input Devices
Storage
DMI
Resources
Benchmarks
CPU Blowfish
CPU CryptoHash
CPU Fibonacci
CPU N-Queens
FPU FFT
/root/my-applications/bin/measure-it: line 8: 28451 Segmentation fault $myprog
Date : 11-06-20
Application : hardinfo -r
Start time : 14:22:38
End time : 14:23:27
Elapsed time : 49 seconds
sh-4.1#
Thanks everyone.
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I made a function called time2 in bashbox that provides finer grained time difference for running a command than time. It uses only the date applet, and could be adapted to simply log the times rather than output the difference.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
When I convert videos I have my script save the start time and the end time in a file in the same directory with the video files so that I can go back later and read through the file and see how long a bunch of different conversions took. (I'm always looking for ways to speed up such things.) Here is my vob2avi script that does it:
Notice that I have this script always writing to the done.txt file with echo and date using the appending redirection symbols >> so that if there is a done.txt file already there in that folder it simply adds the new values to the end of the existing one instead of overwriting it. That way I can accumulate lots of results that I can look over later at my leisure. (I guess I should also point out that if the file doesn't exist yet then the redirection simply creates it.)
I hope this helps.
Code: Select all
if [ $# -eq 0 ]; then
echo "[34musage: [35mvob2avi <vobfilename>[34m"
echo " vob2avi is a wrapper for mencoder used to rip vobs"
echo " to avi format."
echo " The '.vob' extension can be given or omitted."
echo " NOTE: edit this file to tweak various settings:"
echo " /root/my-applications/bin/vob2avi[30m"
else
F_NAME="`basename \"$1\" .vob`"
echo "$F_NAME" >>done.txt
date +"%A %Y-%m-%d %I:%M:%S %P" >>done.txt
# scale up 720x576->1024x576
# NOTE: audio ID=128
# delay audio 0.2sec
#mencoder "$F_NAME.vob" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1600:v4mv:mbd=2:trell -aid 128 -nosub -vf scale=1024:576,hqdn3d=2:1:2 -audio-delay -0.2 -oac mp3lame -lameopts vbr=3 -o "$F_NAME.avi"
systemsound alert
date +"%A %Y-%m-%d %I:%M:%S %P" >>done.txt
echo >>done.txt
fi
I hope this helps.
[color=blue]A life! Cool! Where can I download one of those from?[/color]