Linux 上の Microsoft Defender for Endpoint で Anacron を使用してウイルス対策スキャンをスケジュールする
適用対象:
Linux 用Microsoft Defenderウイルス対策のスキャンを実行するには、「サポートされているコマンド」を参照してください。
注:
この記事では、Linux for Red Hat Enterprise Linux ディストリビューション (RHEL) のMicrosoft Defender for Endpointをサポートします。
システム要件
Microsoft Defender Endpoint on Linux でウイルス対策スキャンMicrosoft Defenderスケジュールするために必要な次のシステム要件を参照してください。
- Linux サーバーのディストリビューションとバージョン: Red Hat Enterprise Linux 7.2 以降。
- カーネルの FANOTIFY オプションを有効にする必要があります。
Red Hat Linux でのウイルス対策スキャンMicrosoft Defenderスケジュール設定
cron ジョブをスケジュールして、スケジュールに従ってウイルス対策スキャンMicrosoft Defender開始できます。 詳細については、「Linux 上のMicrosoft Defender for Endpointを使用してスキャンをスケジュールする方法」を参照してください。 このプロセスは、デバイスが常に稼働している場合に適切に動作します。
ただし、cron スケジュール中に Linux デバイスがシャットダウンまたはオフラインになっている場合、スキャンは実行されません。 このような状況では、 anacron を 使用してタイムスタンプを読み取り、最後に実行されたジョブを見つけることができます。 スケジュールされた cron ジョブ中にデバイスがシャットダウンされた場合は、次にスケジュールされた時刻まで待機する必要があります。 anacron を使用すると、最後にスキャンが実行された時刻がシステムによって検出されます。 デバイスが cron ジョブを実行しなかった場合は、自動的に起動します。
Red Hat Linux でMicrosoft Defenderウイルス対策スキャンをスケジュールする
スキャンをスケジュールするには、次の手順に従います。
# /etc/anacrontab: configuration file for anacron
# See anacron (8) and anacrontab (5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
RANDOM_DELAY=45
# Anacron jobs will start between 8pm and 11pm.
START_HOURS_RANGE=20-23
# delay will be 5 minutes + RANDOM_DELAY for cron.daily
ファイル内の次の項目に注意してください。
- シェル:シェルは と呼ばれ、 ではなく と
/bin/bash
呼ばれます/bin/sh
。 ジョブを作成するときは、忘れないでください。 - RANDOM_DELAY: ジョブの最大時間 (分単位) について説明します。 この値は、同時に実行されるジョブが多すぎないように、ジョブをオフセットするために使用されます。 この遅延の使用は、VDI ソリューションに最適です。
- START_HOURS_RANGE: ジョブを実行する時間範囲について説明します。
- cron.daily: ジョブ実行の頻度に必要な日数として 1 を記述します。 5 は、デバイスの再起動後に anacron が待機する遅延 (分単位) です。
- シェル:シェルは と呼ばれ、 ではなく と
anacron ジョブを確認します。
ls -lh /etc/cron*
[root@redhat7 /] # ls -lh /etc/cron* - rw - - - - - - -. 1 root root 0 Nov 30 2021 /etc/cron.deny - rw - r - - r - -. 1 root root 451 Dec 27 2013 /etc/crontab /etc/cron.d: total 28k - rw - r - - r - -. 1 root root 128 Nov 30 2021 0hourly - rw - r - - r - -. 1 root root 121 Feb 25 18:11 omilogotate - rw - r - - r - -. 1 root root 118 Feb 25 18:14 omsagent - rw - r - - r - -. 1 root root 79 Feb 25 18:15 OMSConsistencyInvoker - rw - r - - r - -. 1 root root 108 Nov 9 2021 raid-check - rw - r - - r - -. 1 root root 135 Jun 1 22:35 scxagent - rw - - - - - - -. 1 root root 235 Jan 20 2020 sysstat /etc/cron.daily: total 24k - rwxr - xr - x. 1 root root 127 Jun 14 16:49 avscandaily - rwx - - - - - -. 1 root root 219 Aug 7 2019 logrotate - rwxr - xr - x. 1 root root 618 Jul 10 2018 man-db.cron - rwx - - - - - -. 1 root root 208 Nov 9 2017 mlocate - rwx - - - - - -. 1 root root 558 Apr 18 19:03 rhsmd - rwxr - xr - x. 1 root root 114 Apr 8 2021 rhui-update-client /etc/cron.hourly: total 8.0k - rwxr - xr - x. 1 root root 392 Nov 30 2021 0anacron - rwxr - xr - x. 1 root root 131 Jun 14 17:05 update /etc/cron.monthly: total 0 - rwxr - xr - x. 1 root root 0 Jun 14 17:47 mdatpupdate /etc/cron.weekly: total 0
ディレクトリを
/etc/cron.d
無視すると、 が表示/etc/cron.daily, hourly, monthly, and weekly
されます。毎週のウイルス対策スキャンをスケジュールするには、ディレクトリの下にファイル (ジョブ) を
/etc/cron.weekly
作成します。cd /etc/cron.weekly vi mdavfullscan Press Insert
#!/bin/sh set -e echo $(date) "Time Scan Begins" >>/logs/mdav_avacron_full_scan.log /bin/mdatp scan full >> /logs/mdav_avacron_full_scan.log echo $(date) "Time Scan Finished" >>/logs/mdav_avacron_full_scan.log exit 0 ~ Press Esc Type: wq!
ファイルの実行を許可するようにファイルのアクセス許可を変更します。
Chmod 755 mdavfullscan ls -la
[root@redhat7 cron.weekly]# ls -la total 16 drwxr - xr - x. 2 root root 26 Jun 14 19:19 . drwxr - xr - x. 85 root root 8192 Jun 14 19:01 .. - rw - r - - r - -. 1 root root 128 Jun 14 19:19 mdavfullscan [root@redhat7 cron.weekly] # chmod 755 mdavfullscan [root@redhat7 cron.weekly] # ls -lh total 4. 0k - rwxr - xr - x. 1 root root 128 Jun 14 19:19 mdavfullscan [root@redhat7 cron.weekly] #
週単位の anacron ジョブをテストするには、 コマンドを使用します。
./mdavfullscan
コマンドを使用して、ジョブが正常に実行されたことを確認します。
cat /logs/mdav_avacron_full_scan.log
[root@redhat7 cron.weekly] # cat /logs/mdav_avacron_full_scan.log Tue Jun 14 20:20:44 UTC 2022 Time Scan Begins Scan has finished 66547 file(s) scanned 0 threat(s) detected Tue Jun 14 20:20:50 UTC 2022 Time Scan Finished [root@redhat7 cron.weekly] #
ヒント
さらに多くの情報を得るには、 Tech Community 内の Microsoft Security コミュニティ (Microsoft Defender for Endpoint Tech Community) にご参加ください。
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示