WindowでもLinuxのps
コマンドみたいにメモリを監視したい。
以下を参考にした。
takigawa401.hatenablog.com
chkmmr.bat
というバッチファイルを作成する。
@echo off :label01 echo %date% %time% tasklist /fi "imagename eq python.exe" ping localhost -n 1 > nul goto label01
pythonのスクリプトが使用するメモリを監視したかったため、少し変更を加えた。
/fi "imagename eq python.exe"
でpythonの実行ログのみにフィルタリングしている。
また、1秒ごとにログを取りたかったので-n 1
を指定している。
実行。結果はファイルに書き出したいため> python.log
を付ける。
> chkmmr.bat > python.log
python.log
に結果が出力されている。
2018/09/11 12:42:56.37 INFO: No tasks are running which match the specified criteria. 2018/09/11 12:42:56.49 INFO: No tasks are running which match the specified criteria. 2018/09/11 12:42:56.62 INFO: No tasks are running which match the specified criteria. 2018/09/11 12:42:56.74 Image Name PID Session Name Session# Mem Usage ========================= ======== ================ =========== ============ python.exe 26856 Console 1 1,456 K 2018/09/11 12:42:56.87 Image Name PID Session Name Session# Mem Usage ========================= ======== ================ =========== ============ python.exe 26856 Console 1 17,604 K 2018/09/11 12:42:57.01 ・ ・ ・ Image Name PID Session Name Session# Mem Usage ========================= ======== ================ =========== ============ python.exe 26856 Console 1 712,056 K 2018/09/11 12:43:17.21 Image Name PID Session Name Session# Mem Usage ========================= ======== ================ =========== ============ python.exe 26856 Console 1 421,124 K 2018/09/11 12:43:17.36 Image Name PID Session Name Session# Mem Usage ========================= ======== ================ =========== ============ python.exe 26856 Console 1 153,112 K 2018/09/11 12:43:17.51 Image Name PID Session Name Session# Mem Usage ========================= ======== ================ =========== ============ python.exe 26856 Console 1 17,076 K 2018/09/11 12:43:17.66 INFO: No tasks are running which match the specified criteria. 2018/09/11 12:43:17.81 INFO: No tasks are running which match the specified criteria.
cmdでもメモリ監視できました!