dstatがcronと共にインストールされていません。

dstatがcronと共にインストールされていません。

特定の条件が満たされると、インストールプロセスをトリガーするcronによってトリガーされるサイレントインストールbashスクリプトがあります。本質的には次のようになります。

#!/bin/bash

if [[ -f "/usr/bin/apt-get" ]]; then
    if [[ ! -f "/usr/bin/dstat"  ]]; then
        apt-get update && apt-get install -y dstat > /tmp/dstat.log
    fi
fi

上記のスクリプトは、dstatインストールされていないと判断された場合にインストールするように設計されています。このスクリプトを手動で実行すると、すべてが期待どおりに機能します。出力は次/tmp/dstat.logのとおりです。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  dstat
0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded.
Need to get 0 B/68.2 kB of archives.
After this operation, 351 kB of additional disk space will be used.
Selecting previously unselected package dstat.
(Reading database ... 33233 files and directories currently installed.)
Preparing to unpack .../dstat_0.7.2-3build1_all.deb ...
Unpacking dstat (0.7.2-3build1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up dstat (0.7.2-3build1) ...

dstatインストールが成功しました。次に、crontabに新しいエントリを追加し、スクリプトが定期的に実行されるようにします。インストールされてdstatおらず、出力は次のとおりです。

Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  dstat
0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded.
Need to get 0 B/68.2 kB of archives.
After this operation, 351 kB of additional disk space will be used.

本当に混乱しています。

ベストアンサー1

おすすめ記事