fiddlehead_cons Posted December 20, 2006 Share Posted December 20, 2006 Phellow Phreaks!I'm trying to track the CPU usage of a short Linux script that I wrote called clientFeeder.do. I want to grep out the system cpu time and log it into a file. However, when I run the command:time . clientFeeder.do >> grep sys 2>&1I get all three times, real, user, and sys.real 0m1.685suser 0m0.033ssys 0m0.027sCan anyone tell me what I'm doing wrong? ??? I just want the sys time, not the other two lines. Thanks! Warm regards,James Quote Link to comment https://forums.phpfreaks.com/topic/31314-grepping-the-linux-time-command/ Share on other sites More sharing options...
neylitalo Posted December 20, 2006 Share Posted December 20, 2006 well, you're close, but not quite - the syntax would actually be:[code]$ time foobar 2>&1 | grep sys[/code]It's odd, though - grep still doesn't seem to catch it, when I try it. Other stderr redirection works fine for me, but not with time. I suspect it's because time is a utility within bash, and that throws things off, for whatever reason. Quote Link to comment https://forums.phpfreaks.com/topic/31314-grepping-the-linux-time-command/#findComment-144946 Share on other sites More sharing options...
ypirc Posted January 3, 2007 Share Posted January 3, 2007 Alternatively, you could use the "time" bin and not the bash "builtin" command. The benefit of this is that it has a "format" flag that you can pass to _only_ return what you want.[quote]# /usr/bin/time -f "%S" ls >/dev/null0.00[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/31314-grepping-the-linux-time-command/#findComment-152509 Share on other sites More sharing options...
neylitalo Posted January 3, 2007 Share Posted January 3, 2007 Oh, excellent. If you haven't got the GNU time utility, it's available at http://ftp.gnu.org/pub/gnu/time/time-1.7.tar.gz, in Gentoo's Portage as sys-process/time and in Debian's stable repos as utils/time. Quote Link to comment https://forums.phpfreaks.com/topic/31314-grepping-the-linux-time-command/#findComment-152522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.