次の方法で共有


Linux 上の Microsoft Defender for Endpoint で Anacron を使用してウイルス対策スキャンをスケジュールする

適用対象:

  • サーバーのMicrosoft Defender for Endpoint
  • サーバープラン 1 またはプラン 2 のMicrosoft Defender
  • Microsoft Defender ウイルス対策

Linux 向けウイルス対策Microsoft Defenderスキャンを実行するには、「サポートされているコマンド」を参照してください。

システム要件

Microsoft Defender Endpoint on Linux でウイルス対策スキャンMicrosoft Defenderスケジュールするために必要な次のシステム要件を参照してください。

  • Linux ディストリビューションとバージョン: Red Hat Enterprise Linux 7.2 以降。
  • カーネルの FANOTIFY オプションを有効にする必要があります。

Linux でのMicrosoft Defender for Endpointの前提条件に関するページも参照してください。

Red Hat Linux でのウイルス対策スキャンMicrosoft Defenderスケジュール設定

cron ジョブをスケジュールして、スケジュールMicrosoft Defenderウイルス対策スキャンを開始できます。 このプロセスは、デバイスが常に稼働している場合に適切に動作します。

ただし、cron スケジュール中に Linux デバイスがシャットダウンまたはオフラインになっている場合、スキャンは実行されません。 このような状況では、 anacron を 使用してタイムスタンプを読み取り、最後に実行されたジョブを見つけることができます。 スケジュールされた cron ジョブ中にデバイスがシャットダウンされた場合は、次にスケジュールされた時刻まで待機する必要があります。 anacron を使用すると、最後にスキャンが実行された時刻がシステムによって検出されます。 デバイスが cron ジョブを実行しなかった場合は、自動的に起動します。

Red Hat Linux でMicrosoft Defenderウイルス対策スキャンをスケジュールする

スキャンをスケジュールするには、次の手順に従います。

  1. PuTTY を使用して RedHat サーバーに接続します。

  2. 次のように anacron ファイルを編集します。

    vi /etc/anacron
    
  3. 次の情報を含む Anacron ファイルを確認して編集します。

    # /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 が待機する遅延 (分単位) です。
  4. 次のコマンドを使用して、anacron ジョブを確認します。

    ls -lh /etc/cron*
    

    次のスクリーンショットに示すような情報が表示されます。

    サンプル Anacron Job Linux。

    次のコード例では、より詳細なビューを提供します。

    [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を確認してください。

  5. 毎週のウイルス対策スキャンをスケジュールするには、 /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
    /usr/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!
    
  6. 次のコマンドを使用して、ファイルの実行を許可するようにファイルのアクセス許可を変更します。

    Chmod 755 mdavfullscan
    
    ls -la
    

    7. ファイルのアクセス許可を変更する

    [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] #
    
  7. 毎週の anacron ジョブをテストするには、次のコマンドを使用します。

    ./mdavfullscan
    
  8. 次のコマンドを使用して、ジョブが正常に実行されたことを確認します。

    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) にご参加ください。