linux_introduction/assets/processes_ex_01.py

14 lines
286 B
Python

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))