bash - egrep output doesn't forward all lines to file -


i trying compose command monitor stability of script on server curling every couple of minutes (actual path script replaced):

while :; date +"%t" >> monitor.txt; time curl -is http://googel.com | egrep "http|m.\." >> monitor.txt; echo ================ >> monitor.txt; sleep 30; done 

the problem reason part of output not forwarded file monitor.txt. file contains following lines:

$ cat monitor.txt 19:39:10 http/1.1 301 moved permanently ================ 19:39:40 http/1.1 301 moved permanently ================ 

..while time details go default output:

$ while :; date +"%t" >> monitor.txt; time curl -is http://googel.com | egrep "http|m.\." >> monitor.txt; echo ================ >> monitor.txt; sleep 30; done  real    0m0.075s user    0m0.005s sys     0m0.003s  real    0m0.106s user    0m0.004s sys     0m0.005s 

could please point out, missing here? run command in background , check monitor.txt results.

thank in advance!

the time command sends output stderr, not stdout. redirection affects stdout, time output ends going console.

to add confusion, bash has builtin time command, bit trickier redirect. if use /usr/bin/time instead of time, should able redirect output 2>&1 syntax. or if prefer bash builtin version of command, can see this answer way redirect output.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -