Sponsored Content
Top Forums Shell Programming and Scripting Time taken to run a SQL script Post 302798161 by hanson44 on Wednesday 24th of April 2013 01:53:53 AM
Old 04-24-2013
Code:
$ which time
/usr/bin/time

Code:
$ cat test.sh
rm -f logfile
time_cmd="/usr/bin/time --format=%E --append --output=logfile"

echo 'Elapsed time taken, [hours:]minutes:seconds.' >> logfile

echo Running command 1 ... >> logfile
$time_cmd sleep 0

echo Running command 2 ... >> logfile
$time_cmd sleep 1

echo Running command 3 ... >> logfile
$time_cmd sleep 2

echo Running command 4 ... >> logfile
$time_cmd sleep 0

echo Running command 5 ... >> logfile
$time_cmd sleep 1

echo Running command 6 ... >> logfile
$time_cmd sleep 2

Code:
$ cat logfile
$ cat logfile
Elapsed time taken, [hours:]minutes:seconds.
Running command 1 ...
0:00.00
Running command 2 ...
0:01.00
Running command 3 ...
0:02.00
Running command 4 ...
0:00.00
Running command 5 ...
0:01.00
Running command 6 ...
0:02.00

Substitute the SQL commands for the "sleep N" commands.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

can nested SQl be run in Unix Script?

can nested SQl be run in Unix Script? I tried some and found only simply sql(one select) can work well in unix script. (21 Replies)
Discussion started by: YoYo
21 Replies

2. Shell Programming and Scripting

How to run an SQL script inside a shell

How do I create a K Shell which would silently (without user input) logon to Oracle and run an SQL script? Any help will be greatly appreciated. Steve (1 Reply)
Discussion started by: stevefox
1 Replies

3. UNIX for Dummies Questions & Answers

problem to run sql startment in script

Hello, I have a script to run a list of customer information, but it not work. can anyone help below: echo "Please input list to check customer detail:" read list for file in 'cat $list.txt' do echo "select cuname as "FROM CUNAME", invo_num as "RECS", total_amount as "AMOUNT", tax_amount as... (7 Replies)
Discussion started by: happyv
7 Replies

4. Shell Programming and Scripting

shell script to run .sql files

hi Friends, Please help me in writing shell script to run list of sql files. database is Oracle 9i, unix os is solaris Requirement is 1. sql file must take two inputs a)feed id and b)business date 2.shell script must out put .xls or .csvfile as out put without trimming any column name and... (1 Reply)
Discussion started by: balireddy_77
1 Replies

5. Shell Programming and Scripting

run sql query via perl script

Hello, If I run this command on the server it works. # dbc "update config set radio_enabled = 0;" how can I execute the same command in perl. I have defined the dbc path. Can any one please correct the last line. #!/usr/bin/perl #database path $dbc='/opt/bin/psql -Userver... (0 Replies)
Discussion started by: sureshcisco
0 Replies

6. Shell Programming and Scripting

Run Sql plus in shell script

Hello, I want to connect to ssh, run a query, and store that into a variable in the shell script. Also I need to pass the variable back to php to display the query results. I have created a public/private key pair for ssh connection and that is working fine. Also I am able to run query in the... (8 Replies)
Discussion started by: shekhar2010us
8 Replies

7. Shell Programming and Scripting

Run SQL thru shell script: how to get a new line when run sql query?

Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database. I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :( What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies

8. Shell Programming and Scripting

Run sql script and send to mail if not empty?

Thanks again for helping me out. I was wondering if anyone else has encountered this issue. I have a SQL script that produces a list -however we are only interested in that list if the length is not zero Here is the sql file named dailyBalance.sql select * from Balance where... (1 Reply)
Discussion started by: Astrocloud
1 Replies

9. UNIX for Dummies Questions & Answers

Script to run sql query.

Please read How To Ask Questions The Smart Way (1 Reply)
Discussion started by: balu_279013
1 Replies

10. Shell Programming and Scripting

run sql queries from UNIX shell script.

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX? :confused: (1 Reply)
Discussion started by: 24ajay
1 Replies
LOGSAVE(8)						      System Manager's Manual							LOGSAVE(8)

NAME
logsave - save the output of a command in a logfile SYNOPSIS
logsave [ -asv ] logfile cmd_prog [ ... ] DESCRIPTION
The logsave program will execute cmd_prog with the specified argument(s), and save a copy of its output to logfile. If the containing directory for logfile does not exist, logsave will accumulate the output in memory until it can be written out. A copy of the output will also be written to standard output. If cmd_prog is a single hyphen ('-'), then instead of executing a program, logsave will take its input from standard input and save it in logfile logsave is useful for saving the output of initial boot scripts until the /var partition is mounted, so the output can be written to /var/log. OPTIONS
-a This option will cause the output to be appended to logfile, instead of replacing its current contents. -s This option will cause logsave to skip writing to the log file text which is bracketed with a control-A (ASCII 001 or Start of Header) and control-B (ASCII 002 or Start of Text). This allows progress bar information to be visible to the user on the console, while not being written to the log file. -v This option will make logsave to be more verbose in its output to the user. AUTHOR
Theodore Ts'o (tytso@mit.edu) SEE ALSO
fsck(8) E2fsprogs version 1.44.1 March 2018 LOGSAVE(8)
All times are GMT -4. The time now is 04:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy