Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, What is a command in bash script to get time same like time in perl? Time in seconds. I just want to calculate how long will it take to ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Location
    Tacoma, Washington
    Posts
    8

    time in bash

    Hi,
    What is a command in bash script to get time same like time in perl? Time in seconds. I just want to calculate how long will it take to run my process. Thanks.

    -nodopro

  2. #2
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    Would the %s option in date command work:

    %s seconds since 00:00:00 1970-01-01 UTC (a GNU extension)

    Code:
    #!/bin/bash
    STRT=`date "+%s"`
    sleep 10
    END=`date "+%s"`
    DIFF=$(($END-$STRT))
    echo "Ran $DIFF seconds"

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Location
    Tacoma, Washington
    Posts
    8
    Great. Thanks vsemaska.

    -nodopro

Posting Permissions

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