請問怎麼在.sh檔裡用time輸出指令的執行時間? - Linux

By George
at 2011-02-16T04:08
at 2011-02-16T04:08
Table of Contents
小弟如果直接在command line下列指令:
(time ./a.out) >> test.log
可以把執行./a.out的輸出與其執行時間輸出到test.log這個檔
ex.
./a.out會輸出 Hello World
則test.log裡面的內容會是
Hello World
0.000u 0.001s 0:00.00 0.0% 0+0k 0+0io 0pf+0w
但是同樣在run.sh檔中打
(time ./a.out) >> test.log
執行./run.sh後,test.log裡面的內容卻只有
Hello World
執行時間的資訊不會出現在test.log裡面,而是出現在command line上
而且格式變成
real 0m0.004s
user 0m0.001s
sys 0m0.000s
請問我指令要怎麼在run.sh寫,才能讓test.log這個檔裡面有執行時間的資訊
而且格式是
real 0m0.004s
user 0m0.001s
sys 0m0.000s
這樣子呢?
困擾好久了
一直都試不出來 @@
麻煩高手幫幫忙囉
感激呀
--
(time ./a.out) >> test.log
可以把執行./a.out的輸出與其執行時間輸出到test.log這個檔
ex.
./a.out會輸出 Hello World
則test.log裡面的內容會是
Hello World
0.000u 0.001s 0:00.00 0.0% 0+0k 0+0io 0pf+0w
但是同樣在run.sh檔中打
(time ./a.out) >> test.log
執行./run.sh後,test.log裡面的內容卻只有
Hello World
執行時間的資訊不會出現在test.log裡面,而是出現在command line上
而且格式變成
real 0m0.004s
user 0m0.001s
sys 0m0.000s
請問我指令要怎麼在run.sh寫,才能讓test.log這個檔裡面有執行時間的資訊
而且格式是
real 0m0.004s
user 0m0.001s
sys 0m0.000s
這樣子呢?
困擾好久了
一直都試不出來 @@
麻煩高手幫幫忙囉
感激呀
--
Tags:
Linux
All Comments

By Megan
at 2011-02-16T08:02
at 2011-02-16T08:02

By Gilbert
at 2011-02-18T14:39
at 2011-02-18T14:39

By Madame
at 2011-02-20T23:53
at 2011-02-20T23:53

By Vanessa
at 2011-02-25T13:56
at 2011-02-25T13:56

By Zanna
at 2011-03-01T13:52
at 2011-03-01T13:52

By Kelly
at 2011-03-04T01:49
at 2011-03-04T01:49

By Tom
at 2011-03-05T11:26
at 2011-03-05T11:26

By Adele
at 2011-03-06T10:32
at 2011-03-06T10:32

By Lydia
at 2011-03-10T18:55
at 2011-03-10T18:55
Related Posts
btrfs vs. ext4

By Ivy
at 2011-02-15T00:33
at 2011-02-15T00:33
在debian下(文字模式)使用中文出現亂碼

By Rae
at 2011-02-14T22:46
at 2011-02-14T22:46
ping 不到gateway

By Eden
at 2011-02-14T18:12
at 2011-02-14T18:12
kernel headers?

By Ida
at 2011-02-14T12:41
at 2011-02-14T12:41
Intel PRO/1000 MT 可完全被CentOS支援嗎?

By Erin
at 2011-02-14T11:44
at 2011-02-14T11:44