Bash: Parse the “Real” output of time of a command, check for output string, add time stamp and send it...
Is it error of law to judge on less relevant case law when there is much more relevant one?
How can I kill my goat?
How can Paypal know my card is being used in another account?
Why is the Apollo LEM ladder so far from the ground?
Is it safe if the neutral lead is exposed and disconnected?
Adopting a feral cat
How does one get an animal off of the Altar surreptitiously?
If Trump gets impeached, how long would Pence be president?
How could Nomadic scholars effectively memorize libraries worth of information
Summoning A Technology Based Demon
What do I do with a party that is much stronger than their level?
Composing fill in the blanks
reconstruction filter - How does it actually work?
Are the named pipe created by `mknod` and the FIFO created by `mkfifo` equivalent?
Why do they sell Cat 5 Ethernet splitters if you can’t split the signal?
ECDSA: Why is SigningKey shorter than VerifyingKey
Exploiting the delay when a festival ticket is scanned
Filter search results by multiple filters in one operation
Finding the Maximum of a Continuous Function over a Closed Interval
What is this 4 sharp symbol and what does it mean?
Why is it considered acid rain with pH <5.6?
Polyhedra, Polyhedron, Polytopes and Polygon
When I cite content from a book, should I say "section 2.3.2.1 of book... " or "section 2.3.2.1 of `the` book ..."?
How to store my pliers and wire cutters on my desk?
Bash: Parse the “Real” output of time of a command, check for output string, add time stamp and send it to an output file
Adding a time stamp when moving a file in bashCapture output of a bash command, parse it and store into different bash variablesParse all column elements from a linux bash command outputHow parse a log file for a string, and when found search backwards for another stringSearch for a string in the output of a commandGet the output of the time commandSend command output to screen and syslogOutput result of time command to variable in bash scriptHow can I use the watch command to run a bash script and monitor output file?Trying to parse a string in BASH for [ - _ ]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Not a script person, GUI is my normal jam. 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:25:06 PDT 2019 real 0m15.653s Failed
I'm sure someone can one-liner this thing, my bash-fu is weak
bash shell-script
New contributor
Sam L is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Not a script person, GUI is my normal jam. 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:25:06 PDT 2019 real 0m15.653s Failed
I'm sure someone can one-liner this thing, my bash-fu is weak
bash shell-script
New contributor
Sam L is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Not a script person, GUI is my normal jam. 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:25:06 PDT 2019 real 0m15.653s Failed
I'm sure someone can one-liner this thing, my bash-fu is weak
bash shell-script
New contributor
Sam L is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Not a script person, GUI is my normal jam. 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:25:06 PDT 2019 real 0m15.653s Failed
I'm sure someone can one-liner this thing, my bash-fu is weak
bash shell-script
bash shell-script
New contributor
Sam L is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sam L is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sam L is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 46 mins ago
Sam LSam L
1
1
New contributor
Sam L is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sam L is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sam L is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f532836%2fbash-parse-the-real-output-of-time-of-a-command-check-for-output-string-add%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sam L is a new contributor. Be nice, and check out our Code of Conduct.
Sam L is a new contributor. Be nice, and check out our Code of Conduct.
Sam L is a new contributor. Be nice, and check out our Code of Conduct.
Sam L is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f532836%2fbash-parse-the-real-output-of-time-of-a-command-check-for-output-string-add%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown