Capture run time of python script executed inside shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capture run time of python script executed inside shell script
# 1  
Old 04-14-2017
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 time in variable.Any leads would be helpful thanks in advance.
# 2  
Old 04-15-2017
Does this mean you can "time" the python only in production runs and on a production machine? With no changes. No way that I know.

Try this
Code:
python -m cProfile myscript.py

from your command line in a non-production environment. Like where you develop and unit test your code.
# 3  
Old 04-15-2017
Did you consider time? man time:
Quote:
time - run programs and summarize system resource usage
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to run in given time

Hi All, Would like to write a Script which will run between 11am to 3 pm and send the results to output.txt. Please suggest. (2 Replies)
Discussion started by: vasuvv
2 Replies

2. Shell Programming and Scripting

Listen sharp time to run a command inside a script

Hello, Just wondered if there is any possibility to run a command at sharp time inside a script in linux. My question is not about crontab Example: #!/bin/bash cd /home/database for i in * do command 1 if time is 19:00, day is Monday then run command2 if time is 20:00, day is... (10 Replies)
Discussion started by: baris35
10 Replies

3. Shell Programming and Scripting

How to run scripts parallely inside shell script?

Hi , I have 4 scripts example script1,script2,script3,script4 . I have to run script1,script2 and script3 parallely since this 3 scripts dont have dependencies . Once script1,script2 and script3 got completed successfully , I have to trigger script4. Can someone help me on this how to... (10 Replies)
Discussion started by: vinothsekark
10 Replies

4. Shell Programming and Scripting

Run .exe inside shell script

I have to run some shell scripts in Windows using Cygwin. I am able to achieve that using %BASH% --login -i "/cygdrive/d/script.sh" , where %BASH% is an environment variable in Windows set to C:\cygwin\bin\bash.exe. I have a created a Cygwin environment variable $EXE_PATH =... (3 Replies)
Discussion started by: HemanthJayasimh
3 Replies

5. Shell Programming and Scripting

Shell script to run all the python scripts from particular directory

I have N number of python scripts which i am receiving from REST web server and i am saving them in /home/mandar/ . Now i want to write a script to run all the python scripts from this directory and monitor them every minute...if any process is dead or hung it should be restarted by this script. ... (0 Replies)
Discussion started by: Mandar Nandale
0 Replies

6. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

7. Shell Programming and Scripting

Shell script to run a python program on multiple entries in a file

Hello I am trying to run a python program using shell script, which takes a single argument from a file. This file has one entry per line : 1aaa 2bbb 3ccc 4ddd 5eee ... ... ... My shell script runs the program, only for the last entry : #!/bin/sh IFS=$'\n' for line in $(cat... (2 Replies)
Discussion started by: ad23
2 Replies

8. Shell Programming and Scripting

how to run shell script inside expect script?

I have the code like this : shell script continues ... .... expect -c" spawn telnet $ip expect "login:" send \"$usrname\r\" expect "Password:" send \"$passwd\r\" expect "*\>" send \"$cmdstr\r\" ... (1 Reply)
Discussion started by: robbiezr
1 Replies

9. 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

10. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies
Login or Register to Ask a Question