Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: time command

  1. #1
    Join Date
    Apr 2008
    Posts
    22

    Default time command

    Under CentOS i get error message "-f: command not found" when i try to run benchmarks.

    Not sure but if i modify benchmark script from just time to /usr/bin/time all works. Is time some sort of shell's inside command?

    Would it be better to modify all benchmark scripts to use time with full path?

  2. #2

    Default

    Hmmm I had just modified all the scripts the other day from /usr/bin/time to time. That must have been why I had done it that way in the first place, I'll change it back. Sorry about that.

  3. #3
    Join Date
    Aug 2007
    Posts
    6,623

    Default

    time is a builtin when you use bash as sh.

  4. #4
    Join Date
    May 2007
    Location
    Third Rock from the Sun
    Posts
    6,584

    Default

    Yes, according to tldp.org

    "As of version 2.0 of Bash, time became a shell reserved word, with slightly altered behavior in a pipeline."

    There is also the times command that gives statistics on the system time elapsed when executing commands.

  5. #5
    Join Date
    Apr 2008
    Location
    York, UK
    Posts
    134

    Default

    That can't always be the case, since I'm using Bash 3.1
    Code:
    [uncle_fungus@Iguana phoronix-test-suite]$ bash --version
    GNU bash, version 3.1.17(1)-release (i586-mandriva-linux-gnu)
    Copyright (C) 2005 Free Software Foundation, Inc.

    And time in a bash script uses /usr/bin/time

  6. #6
    Join Date
    May 2007
    Location
    Third Rock from the Sun
    Posts
    6,584

    Default

    Quote Originally Posted by uncle_fungus View Post
    That can't always be the case, since I'm using Bash 3.1
    Code:
    [uncle_fungus@Iguana phoronix-test-suite]$ bash --version
    GNU bash, version 3.1.17(1)-release (i586-mandriva-linux-gnu)
    Copyright (C) 2005 Free Software Foundation, Inc.
    And time in a bash script uses /usr/bin/time
    Maybe it's because we are using a newer version of bash.

    Code:
    dean@linux:~> bash --version
    GNU bash, version 3.2.39(1)-release (x86_64-suse-linux-gnu)
    Copyright (C) 2007 Free Software Foundation, Inc.

  7. #7
    Join Date
    Aug 2007
    Posts
    6,623

    Default

    Check this:

    $ bash -c time

    real 0m0.000s
    user 0m0.000s
    sys 0m0.000s
    $ bash -c /usr/bin/time
    Usage: /usr/bin/time [-apvV] [-f format] [-o file] [--append] [--verbose]
    [--portability] [--format=format] [--output=file] [--version]
    [--quiet] [--help] command [arg...]

    Also check

    readlink /bin/sh

  8. #8
    Join Date
    May 2007
    Location
    Third Rock from the Sun
    Posts
    6,584

    Default

    Quote Originally Posted by Kano View Post
    Check this:

    $ bash -c time

    real 0m0.000s
    user 0m0.000s
    sys 0m0.000s
    $ bash -c /usr/bin/time
    Usage: /usr/bin/time [-apvV] [-f format] [-o file] [--append] [--verbose]
    [--portability] [--format=format] [--output=file] [--version]
    [--quiet] [--help] command [arg...]

    Also check

    readlink /bin/sh
    Code:
    dean@linux:~> bash -c time
    
    real    0m0.000s
    user    0m0.000s
    sys     0m0.000s
    dean@linux:~> bash -c /usr/bin/time
    Usage: /usr/bin/time [-apvV] [-f format] [-o file] [--append] [--verbose]
           [--portability] [--format=format] [--output=file] [--version]
           [--help] command [arg...]
    dean@linux:~> readlink /bin/sh
    bash
    dean@linux:~>

  9. #9
    Join Date
    Aug 2007
    Posts
    6,623

    Default

    And thats the standard behaviour if you have /bin/sh as bash to use the bash time builtin. When you write #!/bin/sh scripts with time and you set sh to dash then the external time is used.

  10. #10
    Join Date
    Apr 2008
    Location
    York, UK
    Posts
    134

    Default

    It appears my bash isn't behaving as "standard" then.

    Code:
    [uncle_fungus@Iguana phoronix-test-suite]$ bash -c time
    Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]
           [--portability] [--format=format] [--output=file] [--version]
           [--quiet] [--help] command [arg...]
    [uncle_fungus@Iguana phoronix-test-suite]$ bash -c /usr/bin/time
    Usage: /usr/bin/time [-apvV] [-f format] [-o file] [--append] [--verbose]
           [--portability] [--format=format] [--output=file] [--version]
           [--quiet] [--help] command [arg...]
    [uncle_fungus@Iguana phoronix-test-suite]$ readlink /bin/sh
    bash

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •