Calculating script run time in Solaris OS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calculating script run time in Solaris OS
# 1  
Old 06-05-2013
Calculating script run time in Solaris OS

Hi All,

I have written script and wanted to know the run time of it in seconds. i used below logic but am not getting the results in second instead getting error.

Code:
cat pkloader.sh

# if you want to calculate the time in milliseconds then use $(date +%s%N)
START_TIME=`date +%s`
echo "$START_TIME"

##### logic #######

echo "pkloader execution has completed"
END_TIME=`date +%s`
echo "$END_TIME"
DIFF=$(( $END_TIME - $START_TIME ))
echo "Script took $DIFF seconds to complete"

Error am getting when running the script :
Code:
./pkloader.sh: line 33: %s - %s : syntax error: operand expected (error token is "%s - %s ")

and observed that on line to print START_TIME and END_TIME , i get just %s as output.

this script running in SunOS
# 2  
Old 06-05-2013
Your script works fine on my ubuntu.
PS I do not see the hash bang in your script #!/bin/bash

If you do not need DIFF in a variable
Code:
cat pkloader.sh

# if you want to calculate the time in milliseconds then use $(date +%s%N)
START_TIME=$(date +%s)
echo "$START_TIME"

##### logic #######

echo "pkloader execution has completed"
echo "Script took $(( $(date +%s) - $START_TIME )) seconds to complete"

# 3  
Old 06-05-2013
Just check the man page in your OS whether its %s or %S
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

2. Shell Programming and Scripting

Calculating the running time

Hi All, I want to run a utility for all the process id that are running for more than 15 mins. I have captured process id's and the time that they were run in a file like below 1st column represnts the process ids and the 2nd one is the Time < 21014 01:00 21099 01:00 24361 01:03 24406... (5 Replies)
Discussion started by: r_t_1601
5 Replies

3. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

4. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

5. Shell Programming and Scripting

Backup script calculating which type to run

Hi, Second attempt at this, which I have gone down a different and seemingly long winded route but I don't know what other way to do it. Task - Create a template (or skeleton) script for our backup scripts to sit inside. Background - We currently run our monthly (every 28 days) and... (4 Replies)
Discussion started by: rab
4 Replies

6. Shell Programming and Scripting

Calculating completion time

The date construct in UNIX can be used to calculate when something is finished: date -v+1H displays the time 1 hour from now. I want to use the same construct in a script, but it is leading to error messages: echo "Finished at: " `date -v+$durationH` where $duration is calculated based on input... (3 Replies)
Discussion started by: figaro
3 Replies

7. Shell Programming and Scripting

last run time of any script

how to find when last time a scrit has ran? (7 Replies)
Discussion started by: RahulJoshi
7 Replies

8. Shell Programming and Scripting

calculating the time difference, when the script was executed and the currenent file

Hi, I has created the shell script in HP_UX 11.23 and using the command, echo $(date +%Y%m%d%H%M%S) > $DIR/alert, placing the time of running the script into a file alert. I want to compare the time in the above file alert with the current time.If difference is more than 5 min, then print the... (7 Replies)
Discussion started by: velocitnitin
7 Replies

9. Shell Programming and Scripting

run script for given time

Hi! I need to run my script for a specific number of time, as specified by the user: For instance, if the user specified 10, my script should run for until 10 seconds expire. How do I do this? (0 Replies)
Discussion started by: looza
0 Replies

10. Shell Programming and Scripting

Run script at same time

Hi My five script run throgh crontab at same time at 6 clock. Due to problem in the data load .Now I want to check time of load finish run these jobs. I create a script which check the load finish time but I have no idea how I run these JObs. This is very urget to me. Please reply me as soon... (3 Replies)
Discussion started by: Jamil Qadir
3 Replies
Login or Register to Ask a Question