Bash Shell takes variable amount of time to load
Clash Royale CLAN TAG#URR8PPP
I use bash on Ubuntu 18.04. I have added a lot of functions and a lot of scripts are sourced in my bashrc. I am able to time the total time it takes to load my terminal, sometimes it takes 0.9 seconds to more than a minute. And this happens randomly, not that only at the first time it takes more time.
How can I log and analyze how much time each command in bashrc takes to execute. I hope that the logs are generated every time automatically and when it is slow I could analyse the cause of it.
Any suggestions as to what can be done.
Secondly, would preload daemon be useful to speedup the loading of the terminal. I am not sure about it.
bash logs performance bashrc time
add a comment |
I use bash on Ubuntu 18.04. I have added a lot of functions and a lot of scripts are sourced in my bashrc. I am able to time the total time it takes to load my terminal, sometimes it takes 0.9 seconds to more than a minute. And this happens randomly, not that only at the first time it takes more time.
How can I log and analyze how much time each command in bashrc takes to execute. I hope that the logs are generated every time automatically and when it is slow I could analyse the cause of it.
Any suggestions as to what can be done.
Secondly, would preload daemon be useful to speedup the loading of the terminal. I am not sure about it.
bash logs performance bashrc time
It's not a duplicate. I want time measurement for each command individually.
– Nikhil
Feb 27 at 23:38
1
Your terminal very probably starts up very quickly. You seem to be talking about your shell.
– JdeBP
Feb 27 at 23:54
use the commandtime
to time commands eg.time source ./somefuncsA.bash
– X Tian
Feb 28 at 14:00
add a comment |
I use bash on Ubuntu 18.04. I have added a lot of functions and a lot of scripts are sourced in my bashrc. I am able to time the total time it takes to load my terminal, sometimes it takes 0.9 seconds to more than a minute. And this happens randomly, not that only at the first time it takes more time.
How can I log and analyze how much time each command in bashrc takes to execute. I hope that the logs are generated every time automatically and when it is slow I could analyse the cause of it.
Any suggestions as to what can be done.
Secondly, would preload daemon be useful to speedup the loading of the terminal. I am not sure about it.
bash logs performance bashrc time
I use bash on Ubuntu 18.04. I have added a lot of functions and a lot of scripts are sourced in my bashrc. I am able to time the total time it takes to load my terminal, sometimes it takes 0.9 seconds to more than a minute. And this happens randomly, not that only at the first time it takes more time.
How can I log and analyze how much time each command in bashrc takes to execute. I hope that the logs are generated every time automatically and when it is slow I could analyse the cause of it.
Any suggestions as to what can be done.
Secondly, would preload daemon be useful to speedup the loading of the terminal. I am not sure about it.
bash logs performance bashrc time
bash logs performance bashrc time
edited Feb 28 at 0:44
Nikhil
asked Feb 27 at 23:31
NikhilNikhil
367215
367215
It's not a duplicate. I want time measurement for each command individually.
– Nikhil
Feb 27 at 23:38
1
Your terminal very probably starts up very quickly. You seem to be talking about your shell.
– JdeBP
Feb 27 at 23:54
use the commandtime
to time commands eg.time source ./somefuncsA.bash
– X Tian
Feb 28 at 14:00
add a comment |
It's not a duplicate. I want time measurement for each command individually.
– Nikhil
Feb 27 at 23:38
1
Your terminal very probably starts up very quickly. You seem to be talking about your shell.
– JdeBP
Feb 27 at 23:54
use the commandtime
to time commands eg.time source ./somefuncsA.bash
– X Tian
Feb 28 at 14:00
It's not a duplicate. I want time measurement for each command individually.
– Nikhil
Feb 27 at 23:38
It's not a duplicate. I want time measurement for each command individually.
– Nikhil
Feb 27 at 23:38
1
1
Your terminal very probably starts up very quickly. You seem to be talking about your shell.
– JdeBP
Feb 27 at 23:54
Your terminal very probably starts up very quickly. You seem to be talking about your shell.
– JdeBP
Feb 27 at 23:54
use the command
time
to time commands eg. time source ./somefuncsA.bash
– X Tian
Feb 28 at 14:00
use the command
time
to time commands eg. time source ./somefuncsA.bash
– X Tian
Feb 28 at 14:00
add a comment |
2 Answers
2
active
oldest
votes
You could print timestamps using the Bash tracing mechanism, given that t
is expanded in $PS4
:
$ PS4='+ t> ' bash -x -c "sleep 1; sleep 2; sleep 3"
+ 18:41:05> sleep 1
+ 18:41:06> sleep 2
+ 18:41:08> sleep 3
It should be easy to apply this to tracing your .bashrc
and/or .profile
etc.
add a comment |
- You could put the
time
command before each command in your.bashrc
- To direct the output of the
time
command (and not the command output itself) to a log file, reference this question - You'll probably want to echo out something useful to the log file before each command so that you can identify which command is being timed in the logs.
- (optional) You may also want to run
date
at the beginning of your.bashrc
and direct the output to the log file so that you can see which login event is being timed.
add a comment |
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
);
);
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%2f503444%2fbash-shell-takes-variable-amount-of-time-to-load%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could print timestamps using the Bash tracing mechanism, given that t
is expanded in $PS4
:
$ PS4='+ t> ' bash -x -c "sleep 1; sleep 2; sleep 3"
+ 18:41:05> sleep 1
+ 18:41:06> sleep 2
+ 18:41:08> sleep 3
It should be easy to apply this to tracing your .bashrc
and/or .profile
etc.
add a comment |
You could print timestamps using the Bash tracing mechanism, given that t
is expanded in $PS4
:
$ PS4='+ t> ' bash -x -c "sleep 1; sleep 2; sleep 3"
+ 18:41:05> sleep 1
+ 18:41:06> sleep 2
+ 18:41:08> sleep 3
It should be easy to apply this to tracing your .bashrc
and/or .profile
etc.
add a comment |
You could print timestamps using the Bash tracing mechanism, given that t
is expanded in $PS4
:
$ PS4='+ t> ' bash -x -c "sleep 1; sleep 2; sleep 3"
+ 18:41:05> sleep 1
+ 18:41:06> sleep 2
+ 18:41:08> sleep 3
It should be easy to apply this to tracing your .bashrc
and/or .profile
etc.
You could print timestamps using the Bash tracing mechanism, given that t
is expanded in $PS4
:
$ PS4='+ t> ' bash -x -c "sleep 1; sleep 2; sleep 3"
+ 18:41:05> sleep 1
+ 18:41:06> sleep 2
+ 18:41:08> sleep 3
It should be easy to apply this to tracing your .bashrc
and/or .profile
etc.
answered Feb 28 at 18:41
Toby SpeightToby Speight
5,37711132
5,37711132
add a comment |
add a comment |
- You could put the
time
command before each command in your.bashrc
- To direct the output of the
time
command (and not the command output itself) to a log file, reference this question - You'll probably want to echo out something useful to the log file before each command so that you can identify which command is being timed in the logs.
- (optional) You may also want to run
date
at the beginning of your.bashrc
and direct the output to the log file so that you can see which login event is being timed.
add a comment |
- You could put the
time
command before each command in your.bashrc
- To direct the output of the
time
command (and not the command output itself) to a log file, reference this question - You'll probably want to echo out something useful to the log file before each command so that you can identify which command is being timed in the logs.
- (optional) You may also want to run
date
at the beginning of your.bashrc
and direct the output to the log file so that you can see which login event is being timed.
add a comment |
- You could put the
time
command before each command in your.bashrc
- To direct the output of the
time
command (and not the command output itself) to a log file, reference this question - You'll probably want to echo out something useful to the log file before each command so that you can identify which command is being timed in the logs.
- (optional) You may also want to run
date
at the beginning of your.bashrc
and direct the output to the log file so that you can see which login event is being timed.
- You could put the
time
command before each command in your.bashrc
- To direct the output of the
time
command (and not the command output itself) to a log file, reference this question - You'll probably want to echo out something useful to the log file before each command so that you can identify which command is being timed in the logs.
- (optional) You may also want to run
date
at the beginning of your.bashrc
and direct the output to the log file so that you can see which login event is being timed.
answered Feb 28 at 0:49
CrypteyaCrypteya
414118
414118
add a comment |
add a comment |
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%2f503444%2fbash-shell-takes-variable-amount-of-time-to-load%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
It's not a duplicate. I want time measurement for each command individually.
– Nikhil
Feb 27 at 23:38
1
Your terminal very probably starts up very quickly. You seem to be talking about your shell.
– JdeBP
Feb 27 at 23:54
use the command
time
to time commands eg.time source ./somefuncsA.bash
– X Tian
Feb 28 at 14:00