linux_introduction/assets/processes_ex_01.py

14 lines
286 B
Python
Raw Permalink Normal View History

2022-08-23 09:59:09 +02:00
import time
import os
start_ts = time.time()
loops = 0
while True:
time.sleep(1)
loops += 1
tick_ts = time.time()
delta = int(tick_ts - start_ts)
pid = os.getpid()
print("I'm {} and I've been running for {} seconds and did {} loops".format(pid, delta, loops))