Python | How to get size of all log files in a directory with subprocess python

Python subprocess module is very useful is in automating Linux system administration tasks. Below is the code snippet for getting size of all log files inside "/var/log" directory in Python with subprocess module.

  • Create a file with name "" and write below code.
  • Run the python file with below command and check the output
  • Sample output
  • Categories: Python