LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-26-2004, 02:38 PM   #1
hq4ever
Member
 
Registered: May 2004
Location: Israel
Distribution: Debian
Posts: 98

Rep: Reputation: 15
how to [time] the execution


i've been told that i can time the command execution on linux

how should the syntex be ?
i tried
Code:
time { tar -xvf coreutils-5.2.1.tar && mv coreutils-5.2.1 .. && rm coreutils-5.2.1.tar }
it gives me error 127 : time cannot run {

Last edited by hq4ever; 06-26-2004 at 03:06 PM.
 
Old 06-26-2004, 02:53 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
I'm not sure you can do it that way. AFAIK time can only time one process - you could start a new shell and time it's execution - ie:
time bash -c "echo one && echo two"
 
Old 06-26-2004, 03:05 PM   #3
hq4ever
Member
 
Registered: May 2004
Location: Israel
Distribution: Debian
Posts: 98

Original Poster
Rep: Reputation: 15
david_ross : i'm newbie, i'm just following the book

from LinuxFromScrach 5.1.1, Chapter 5. Constructing a temporary system


Quote:
Note

If you want the SBU values listed in the rest of the book to be of any use, you will have to measure the time it takes to build this package -- from the configuration up to and including the first install. To achieve this easily, you could wrap the four commands in a time command like this: time { ./configure ... && ... && ... && make install; }.
i tried that like it says in the book & it didn't worked, thats why i posted.
 
Old 06-26-2004, 04:36 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Yes, the time command will work that way. You forgot the semicolon at the end of your command string.

It should be:
Code:
time { tar -xvf coreutils-5.2.1.tar && mv coreutils-5.2.1 .. && rm coreutils-5.2.1.tar; }
 
Old 07-02-2004, 03:41 PM   #5
hq4ever
Member
 
Registered: May 2004
Location: Israel
Distribution: Debian
Posts: 98

Original Poster
Rep: Reputation: 15
sorry for the delayed response, my machine just died

any way

i use the command
Code:
time { ../binutils-2.14/configure --prefix=/tools --disable-nls  && make configure-host && make LDFLAGS="-all-static" && make install; }
and i still get the error
Quote:
bash: syntax error near unexpected token '}'
if fact even
Code:
time { echo && echo; }
result in the same error

i am using mandrake 10.0 with bash 2.05b.0(1)-release (i586-mandrake-linux-gnu)
what am i doing wrong ?
 
Old 07-02-2004, 04:14 PM   #6
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
I'm not quite sure what to tell you. My system:

Code:
[dark@spaceball1]$ time { echo foo && echo bar; }
foo
bar

real    0m0.002s
user    0m0.000s
sys     0m0.000s
[dark@spaceball1]$ bash --version
GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.
The time command itself may be different. I couldn't figure out how to coax it into printing its version. No matter what I tried, time tried to interpret "-V". "--help", "--version", and anything else as a command to execute and not an option for time itself.

<edit>
You may be forced to use david_ross's suggesstion: time bash -c "commands"
</edit>

Last edited by Dark_Helmet; 07-02-2004 at 04:16 PM.
 
Old 07-03-2004, 02:39 AM   #7
hq4ever
Member
 
Registered: May 2004
Location: Israel
Distribution: Debian
Posts: 98

Original Poster
Rep: Reputation: 15
nope,
Code:
time { echo foo && echo bar; }
-bash: syntax error near unexpected token '}'
btw
Code:
time -V
GNU time 1.7
may this be a bug in mandrake bash/time ?
should i report it or something ?

Quote:
You may be forced to use david_ross's suggesstion: time bash -c "commands"
can i write a batch file insted (if there is such thing in linux) & time it's execution insted, if so can you write me a quick HowTO for creating this batch please ?

Last edited by hq4ever; 07-03-2004 at 02:41 AM.
 
Old 07-03-2004, 03:57 AM   #8
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
No, I don't think it's a bug, I just think we have two different time programs. "time -V" on my system complains that "-V" is not a valid command/cannot be found. Two different programs, and they approach syntax differently.

The 'time bash -c "command && command && ... " ' is basically a batch file. It's saying to start up a new bash shell only to execute the commands listed, and then quit. The time command gives you the time it took the new bash shell to run those commands. If you don't like doing that though, you can make a shell script.

For instance, type this up in a file named binutils_script.bash (or whatever you like):
Code:
#!/bin/bash

../binutils-2.14/configure --prefix=/tools --disable-nls  && make configure-host && make LDFLAGS="-all-static" && make install
make the file executable: chmod u+x binutils_script.bash

and then you can time it like this: time /path/to/binutils_script.bash

Keep in mind, you will need to be in the binutils directory when you execute the script for it to work properly (just like you would if you were typing the commands given in the book).

You'll have to create a script for each package, or just continue to modify the same one repeatedly for each package you install.
 
Old 07-03-2004, 04:57 AM   #9
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,198

Rep: Reputation: 53
/# time { echo foo && echo bar; }
foo
bar
real 0m0.000s
user 0m0.000s
sys 0m0.000s
/# time ( echo foo && echo bar; )
foo
bar
real 0m0.000s
user 0m0.000s
sys 0m0.000s
/# time ( echo foo && echo bar )
foo
bar
real 0m0.000s
user 0m0.000s
sys 0m0.000s
/#


i had always used ()'s with time. i guess it doesn't matter.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
command execution time minil Programming 10 08-20-2010 04:59 PM
Remote Execution issinho Linux - Networking 5 07-08-2005 01:11 PM
How to tell where the execution is going on right now? bahadur Programming 7 04-03-2005 03:42 AM
How do I Set MySQL Max Query Execution Time? farmerjoe Linux - General 1 01-26-2005 01:12 PM
command execution leonidas Linux - General 1 09-22-2004 12:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration