0

For example i want to count number of files in a directory in real time. As python script will be running continuously in background, when i add a file in the directory, value of count variable updates in my script. So, i need a solution with which pyton script keeps running and updates vcalue in runtime.

divyjot singh
  • 51
  • 1
  • 1
  • 5

2 Answers2

0

You can use 'task scheduler' if you are using windows, or 'crontab' if you are using linux, those will run the scrip in the background for you. There are different ways to do the thing that you are asking for. For example, you can run the script that counts the files, and each time it runs, writes the number of files it found to a txt file somewhere.

Max
  • 907
  • 2
  • 13
  • 27
0

You can use a package called "threading", which runs the code every n seconds(minutes, hours etc.)

Anna Ignashkina
  • 467
  • 4
  • 16