Let's say I've written a script in python, program.py
. I decide to run this in the Terminal using python program.py
.
This code runs through an exceptional amount of data, and takes several hours to run.
Is there any way I can check on the status of this code without stoping the program?
You can try "strace" on the server where your script is running (assuming it is a Linux distro).
I am sure there are bunch of other ways to get this similar result but strace has been my friend.
Say here is my simple script:
[root@buzz tmp]# cat temp.py
#!/usr/bin/python
import time
for i in range(9999):
print "Printing for %s time" % str(i)
time.sleep(1)
[root@buzz tmp]#
And here is the strace output:
[root@buzz ~]# strace -p 10071
Process 10071 attached - interrupt to quit
select(0, NULL, NULL, NULL, {0, 736733}) = 0 (Timeout)
write(1, "Printing for 16 time\n", 21) = 21
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
write(1, "Printing for 17 time\n", 21) = 21
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
write(1, "Printing for 18 time\n", 21) = 21
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
write(1, "Printing for 19 time\n", 21) = 21
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
write(1, "Printing for 20 time\n", 21) = 21
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
write(1, "Printing for 21 time\n", 21) = 21
select(0, NULL, NULL, NULL, {1, 0}^C <unfinished ...>
Process 10071 detached
[root@buzz ~]#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With