Not a script person. I am trying to build a repetitive test to see how long a command takes to run, marks if it's successful or not, and adds a time stamp, and appends everything to a log file.
Oh, and this is in bash on a mac.
To try to parse out just the "real" I've tried things like:
time ./login.sh | sed -n 's/.*real://p' >> output.txt
or
(time ./login.sh) 1> /dev/null 2> output.txt
The login.sh script runs, where it appends Succeeded or Failed:
application login -u "user" -p '******' "host.domain.com" | grep "Succeeded" &> /dev/null
if [ $? == 0 ]; then
echo " Suceeded" >> output.txt
else
echo " Failed" >> output.txt
fi
I'm going to put all of that into a For Loop with a sleep command so that it occurs every 5 minutes:
for n in {1..1000};
do
# Command that Adds the time stamp
# the command to find the real time above once I get it working
sleep 5m
done
Desired Output would be akin to:
Sun Jul 29 16:15:06 PDT 2019 real 0m0.815s Suceeded
Sun Jul 29 16:20:06 PDT 2019 real 0m0.635s Suceeded
Sun Jul 29 16:25:06 PDT 2019 real 0m1.053s Suceeded
Sun Jul 29 16:30:06 PDT 2019 real 0m15.653s Failed