From 1e7805788df0591a6007042e564a5b3b9d00b959 Mon Sep 17 00:00:00 2001
From: florian030 <florian@schaal-24.de>
Date: Tue, 18 Feb 2014 10:19:53 -0500
Subject: [PATCH] Merge branch 'master' of http://git.ispconfig.org/ispconfig/ispconfig3
---
server/plugins-available/cron_plugin.inc.php | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/server/plugins-available/cron_plugin.inc.php b/server/plugins-available/cron_plugin.inc.php
index 21d72e6..d02b1fd 100644
--- a/server/plugins-available/cron_plugin.inc.php
+++ b/server/plugins-available/cron_plugin.inc.php
@@ -193,7 +193,7 @@
$chr_cmd_count = 0;
//* read all active cron jobs from database and write them to file
- $cron_jobs = $app->db->queryAllRecords("SELECT c.`run_min`, c.`run_hour`, c.`run_mday`, c.`run_month`, c.`run_wday`, c.`command`, c.`type`, `web_domain`.`domain` as `domain` FROM `cron` as c INNER JOIN `web_domain` ON `web_domain`.`domain_id` = c.`parent_domain_id` WHERE c.`parent_domain_id` = ".intval($this->parent_domain["domain_id"]) . " AND c.`active` = 'y'");
+ $cron_jobs = $app->db->queryAllRecords("SELECT c.`run_min`, c.`run_hour`, c.`run_mday`, c.`run_month`, c.`run_wday`, c.`command`, c.`type`, c.`log`, `web_domain`.`domain` as `domain` FROM `cron` as c INNER JOIN `web_domain` ON `web_domain`.`domain_id` = c.`parent_domain_id` WHERE c.`parent_domain_id` = ".intval($this->parent_domain["domain_id"]) . " AND c.`active` = 'y'");
if($cron_jobs && count($cron_jobs) > 0) {
foreach($cron_jobs as $job) {
if($job['run_month'] == '@reboot') {
@@ -201,20 +201,38 @@
} else {
$command = str_replace(" ", "", $job['run_min']) . "\t" . str_replace(" ", "", $job['run_hour']) . "\t" . str_replace(" ", "", $job['run_mday']) . "\t" . str_replace(" ", "", $job['run_month']) . "\t" . str_replace(" ", "", $job['run_wday']);
}
+
+ $log_target = ">/dev/null 2>&1";
+ $log_wget_target = '/dev/null';
+ $log_root = '';
+ if($job['log'] == 'y') {
+ if($job['type'] != 'chrooted') $log_root = $this->parent_domain['document_root'];
+ $log_root .= '/log';
+
+ $log_target = '>>' . $log_root . '/cron.log 2>>' . $log_root . '/cron_error.log';
+ $log_wget_target = $log_root . '/cron_wget.log';
+ }
+
$command .= "\t{$this->parent_domain['system_user']}"; //* running as user
if($job['type'] == 'url') {
- $command .= "\t{$cron_config['wget']} -q -t 1 -T 7200 -O /dev/null " . escapeshellarg($job['command']) . " >/dev/null 2>&1";
+ $command .= "\t{$cron_config['wget']} -q -t 1 -T 7200 -O " . $log_wget_target . " " . escapeshellarg($job['command']) . " " . $log_target;
} else {
+ $web_root = '';
if($job['type'] == 'chrooted') {
if(substr($job['command'], 0, strlen($this->parent_domain['document_root'])) == $this->parent_domain['document_root']) {
//* delete the unneeded path part
$job['command'] = substr($job['command'], strlen($this->parent_domain['document_root']));
}
+ } else {
+ $web_root = $this->parent_domain['document_root'];
}
+
+ $web_root .= '/web';
+ $job['command'] = str_replace('[web_root]', $web_root, $job['command']);
$command .= "\t";
- if($job['type'] == 'chrooted' && substr($job['command'], 0, 1) != "/") $command .= $this->parent_domain['document_root'].'/';
- $command .= $job['command'];
+ if($job['type'] != 'chrooted' && substr($job['command'], 0, 1) != "/") $command .= $this->parent_domain['document_root'].'/';
+ $command .= $job['command'] . " " . $log_target;
}
if($job['type'] == 'chrooted') {
--
Gitblit v1.9.1