Skip to content

Commit 5d8d428

Browse files
committed
Run du only if we have records, to avoid No such file or directory error.
1 parent e6752a7 commit 5d8d428

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

server/lib/classes/cron.d/100-monitor_hd_quota.inc.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function onRunJob() {
5959

6060
//* Initialize data array
6161
$data = array();
62+
$df = array();
6263

6364
//* the id of the server as int
6465
$server_id = intval($conf['server_id']);
@@ -72,19 +73,21 @@ public function onRunJob() {
7273
if(!$app->system->is_installed('setquota')) {
7374
//* No Quota on this System ...
7475

75-
//** Fetch the data for all users
76-
$dfData = shell_exec('du -s /var/www/clients/client*/web[0-9]*');
77-
78-
//* split into array
79-
$df = explode("\n", $dfData);
80-
8176
//* Get Limits for Calculation
8277
$records = $app->db->queryAllRecords('SELECT hd_quota, system_user, system_group FROM `web_domain` WHERE `server_id` = ?', $conf['server_id']);
8378
foreach ($records as $record) {
8479
$options['group'][$record['system_group']] = $record['hd_quota']*1024;
8580
$options['user'][$record['system_user']] = $record['hd_quota']*1024;
8681
}
8782

83+
if (!empty($records)) {
84+
//** Fetch the data for all users
85+
$dfData = shell_exec('du -s /var/www/clients/client*/web[0-9]*');
86+
87+
//* split into array
88+
$df = explode("\n", $dfData);
89+
}
90+
8891
//* Loop over all the output lines, for groups.
8992
for ($i = 0; $i <= sizeof($df); $i++) {
9093
if (isset($df[$i]) && $df[$i] != '') {

0 commit comments

Comments
 (0)