0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows からファイルサーバーへ定期的に接続性をチェックしたい

Last updated at Posted at 2025-03-14

掲題の通り、定期的にファイルサーバーとの接続性を記録する方法のサンプルです。
タスクスケジューラーを利用し、1分毎にファイルサーバー上のファイルにアクセスしています。

まず、以下の内容で「connection-test.bat」ファイルを作成します。(xxxxxxxx.example.comはファイルサーバーのドメインまたはIPアドレスに置き換えてください。)
保存場所は問いません。

echo %date% %time% >> \\xxxxxxxx.example.com\share\test.txt

次に、タスクスケジューラーを起動します。

スクリーンショット 2025-03-14 18.08.35.png

「Action > Create Task...」を選択し、タスク作成画面を開きます。

スクリーンショット 2025-03-14 18.09.23.png

「Name」に「ConnectionTest」を入力し、「Run whether user is logged on or not」をチェックします。

スクリーンショット 2025-03-14 18.28.33.png

「Triggers」タブを選択します。

「New...」を選択し、New Trigger ダイアログを起動します

「Advanced settings」で「Repeat task every」を「1 minute」 、「for a duration of」を「Indefinitey」にします。「1 minute」は選択肢に出てきませんが、直接入力することができます。

スクリーンショット 2025-03-14 18.13.54.png

「Ok」を選択し、一覧に追加されていることを確認します。
スクリーンショット 2025-03-14 18.17.41.png

「Actions」タブを開き、「New...」を選択します。

「Program/script:」に先ほど作成した「connection-test.bat」を指定します。

スクリーンショット 2025-03-14 18.20.59.png

「OK」を選択し、一覧に反映します。

スクリーンショット 2025-03-14 18.22.09.png

(オプション)「Conditions」タブで「Power」のチェックを外します。

スクリーンショット 2025-03-14 18.31.19.png

(オプション)「Settings」タブで「Stop the task if it run loger than」、「If the task is not scheduled to run again, delete it after」のチェックを外します。

スクリーンショット 2025-03-14 18.35.22.png

「OK」を選択します。

ユーザー・パスワードを入力し、「OK」を選択します。

スクリーンショット 2025-03-14 18.36.23.png

「Active Tasks」に登録されていることを確認します。
スクリーンショット 2025-03-14 18.49.25.png

「ConnectionTest」を選択すると、「Next Run Time」などの情報を確認できます。
スクリーンショット 2025-03-14 18.51.02.png

1,2分ほど待つと、「bat」ファイルで指定したファイル(\xxxxxxxx.example.com\share\test.txt)が作成され、実行時間が記録されていることが確認できます。

スクリーンショット 2025-03-14 19.01.33.png

これで、何かファイルサーバーとの問題が発生した場合はこのファイルを参照することで接続に問題があったかを確認できます。
もし、ファイルサイズが気になる場合は日次でファイル名を変更するように「.bat」を修正してください。
この場合ファイル数が多くなるため、1週間以上前のファイルを削除するタスクスケジュールを仕込むなどの対策も検討しましょう

「test.txt」が作成されない場合
「History」からエラーが起きていないか確認してください。

スクリーンショット 2025-03-14 19.00.41.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?