Sponsored Content
Full Discussion: Bash script time script
Top Forums Shell Programming and Scripting Bash script time script Post 302988271 by SkySmart on Thursday 22nd of December 2016 06:10:24 PM
Old 12-22-2016
Bash script time script

I have the following code which i'd like to rewrite in a way that it can be used on all unix systems. meaning, i want it to be portable:

Code:
# turn seconds into real measurable time

                                            num=$1
                                            min=0
                                            hour=0
                                            day=0
                                            if((num>59));then
                                                ((sec=num%60))
                                                ((num=num/60))
                                                if((num>59));then
                                                    ((min=num%60))
                                                    ((num=num/60))
                                                    if((num>23));then
                                                        ((hour=num%24))
                                                        ((day=num/24))
                                                    else
                                                        ((hour=num))
                                                    fi
                                                else
                                                    ((min=num))
                                                fi
                                            else
                                                ((sec=num))
                                            fi
                                            echo "$day"d,"$hour"h,"$min"m,"$sec"s

the shell i intend to use is basic shell..i.e. /bin/sh but as many of you can tell already, the above is written in newer form of bash which is simply not available on some systems.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash script to count the time of transaction

Halo, Bash Script can get the time of process the trasaction or not? For example, bash script use to procee the trasaction, like select and checking.. then generate the XML. after it, i need to get the time which to count the process. Anyone can help me? Thank you (1 Reply)
Discussion started by: ryanW
1 Replies

2. Shell Programming and Scripting

execution time / runtime -- bash script please help!

Hello, I'm running a bash script and I'd like to get more accurate a runtime information then now. So far I've been using this method: STARTM=`date -u "+%s"` ......... *script function.... ......... STOPM=`date -u "+%s"` RUNTIMEM=`expr $STOPM - $STARTM` if (($RUNTIMEM>59)); then... (6 Replies)
Discussion started by: TehOne
6 Replies

3. Shell Programming and Scripting

Changing File Time Stamp (Bash Script)

I need some help recovering from a "slight" screwup. We just moved 3 TB of data from one RAID Array to another. Low lever archive files. This was done with a regular cp (for some reason) and now we have lost all the timestamps on the files, and we urgently need to get the timestamps back on these... (7 Replies)
Discussion started by: chj
7 Replies

4. Shell Programming and Scripting

How to compare time in bash script?

Hi, Anyone know how to compare the time in bash script? I want to compare say 30 min. to 45 min. ( AIX ) Thanks. (1 Reply)
Discussion started by: sumit30
1 Replies

5. Shell Programming and Scripting

Need bash script to ping the servers and rename the output file each time the script is ran

HI, I have a file serverlist in that all host names are placed. i have written a small script #./testping #! /bin/bash for i in `cat serverlist` do ping $i >> output.txt done so now it creates a file output.txt till here fine.. now each time i run this script the output file... (4 Replies)
Discussion started by: madhudeva
4 Replies

6. Shell Programming and Scripting

Bash Script Looping all the time

Hello, I have a database file, named data.txt, and a shell script (convert.sh) to convert data.txt from columns to row. Output file name will be column_to_row.txt In this example data.txt has only four rows. Format of data.txt is: info name surname telefon_nr Data.txt info boris... (1 Reply)
Discussion started by: baris35
1 Replies

7. Shell Programming and Scripting

Script in bash that works only some of the time

I ran this script yesterday (in the background) /usr/bin/nohup myfilelocation/myscriptname.sh & the script worked perfectly. i ran it today (also in the background) and just sat there. So i killed it and ran it normally and it worked perfectly. Anyone suggest why it just sat there and... (8 Replies)
Discussion started by: twinion
8 Replies

8. Shell Programming and Scripting

How to add missing date and time in a bash script?

Hi Again, I have a file that contains date and time for the past 2 hours. What i need is add missing date and time in a file. INPUT 2016-01-13 01:33 10 2016-01-13 01:31 10 2016-01-13 01:30 10 2016-01-13 01:29 10 2016-01-13 01:28 10 2016-01-13 01:27 10 2016-01-13 01:26 10 2016-01-13... (14 Replies)
Discussion started by: ernesto
14 Replies

9. Shell Programming and Scripting

Controlling time stamps in a bash script

Hi, I have a bash script that generates CSV (.txt) files at fairly regular time intervals. I'm currently time stamping each batch of measurements at the time I write the rows into a MySQL database. As the result, one set of data might get the time 12:01:32 and the next set of data gets the time... (18 Replies)
Discussion started by: Zooma
18 Replies

10. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies
TCRTEST(1)							   Tokyo Tyrant 							TCRTEST(1)

NAME
tcrtest - test cases of the remote database API DESCRIPTION
The command `tcrtest' is a utility for facility test and performance test. This command is used in the following format. `host' specifies the host name of the server. `rnum' specifies the number of iterations. tcrtest write [-port num] [-cnum num] [-tout num] [-nr] [-rnd] host rnum Store records with keys of 8 bytes. They change as `00000001', `00000002'... tcrtest read [-port num] [-cnum num] [-tout num] [-mul num] [-rnd] host Retrieve all records of the database above. tcrtest remove [-port num] [-cnum num] [-tout num] [-rnd] host Remove all records of the database above. tcrtest rcat [-port num] [-cnum num] [-tout num] [-shl num] [-dai|-dad] [-ext name] [-xlr|-xlg] host rnum Store records with partway duplicated keys using concatenate mode. tcrtest misc [-port num] [-cnum num] [-tout num] host rnum Perform miscellaneous test of various operations. tcrtest wicked [-port num] [-cnum num] [-tout num] host rnum Perform updating operations of list and map selected at random. tcrtest table [-port num] [-cnum num] [-tout num] [-exp num] host rnum Perform miscellaneous test of the table extension. Options feature the following. -port num : specify the port number. -cnum num : specify the number of connections. -tout num : specify the timeout of each session in seconds. -nr : use the function `tcrdbputnr' instead of `tcrdbput'. -rnd : select keys at random. -mul num : specify the number of records for the mget command. -shl num : use `tcrdbputshl' and specify the width. -dai : use `tcrdbaddint' instead of `tcrdbputcat'. -dad : use `tcrdbadddouble' instead of `tcrdbputcat'. -ext name : call a script language extension function. -xlr : perform record locking. -xlg : perform global locking. -exp num : specify the lifetime of expiration test. If the port number is not more than 0, UNIX domain socket is used and the path of the socket file is specified by the host parameter. This command returns 0 on success, another on failure. SEE ALSO
ttserver(1), ttultest(1), ttulmgr(1), tcrmttest(1), tcrmgr(1), ttutil(3), tcrdb(3) Man Page 2010-01-20 TCRTEST(1)
All times are GMT -4. The time now is 09:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy