diff --git a/app.js b/app.js
index fa63511..2e10b30 100755
--- a/app.js
+++ b/app.js
@@ -184,13 +184,23 @@ app.get(routes.import_crontab, function(req, res) {
res.end();
});
-// get the log file a given job. id passed as query param
-app.get(routes.logger, function(req, res) {
- _file = crontab.log_folder +"/"+req.query.id+".log";
- if (fs.existsSync(_file))
- res.sendFile(_file);
+function sendLog(path, req, res) {
+ if (fs.existsSync(path))
+ res.sendFile(path);
else
res.end("No errors logged yet");
+}
+
+// get the log file a given job. id passed as query param
+app.get(routes.logger, function(req, res) {
+ let _file = crontab.log_folder + "/" + req.query.id + ".log";
+ sendLog(_file, req, res);
+});
+
+// get the log file a given job. id passed as query param
+app.get(routes.stdout, function(req, res) {
+ let _file = crontab.log_folder + "/" + req.query.id + ".stdout.log";
+ sendLog(_file, req, res);
});
// error handler
diff --git a/crontab.js b/crontab.js
index 2d492fe..d5c941f 100644
--- a/crontab.js
+++ b/crontab.js
@@ -95,6 +95,7 @@ exports.set_crontab = function(env_vars, callback){
let stderr = path.join(cronPath, tab._id + ".stderr");
let stdout = path.join(cronPath, tab._id + ".stdout");
let log_file = path.join(exports.log_folder, tab._id + ".log");
+ let log_file_stdout = path.join(exports.log_folder, tab._id + ".stdout.log");
if(tab.command[tab.command.length-1] != ";") // add semicolon
tab.command +=";";
@@ -106,6 +107,11 @@ exports.set_crontab = function(env_vars, callback){
"; then date >> \"" + log_file + "\"" +
"; cat " + stderr + " >> \"" + log_file + "\"" +
"; fi";
+
+ crontab_string += "; if test -f " + stdout +
+ "; then date >> \"" + log_file_stdout + "\"" +
+ "; cat " + stdout + " >> \"" + log_file_stdout + "\"" +
+ "; fi";
}
if (tab.hook) {
diff --git a/routes.js b/routes.js
index 210f79e..3770272 100644
--- a/routes.js
+++ b/routes.js
@@ -14,4 +14,5 @@ exports.routes = {
"import": "/import", // this is import from database
"import_crontab": "/import_crontab", // this is from existing crontab
"logger": "/logger",
+ "stdout": "/stdout",
};
diff --git a/views/index.ejs b/views/index.ejs
index 565439b..d2f48dc 100644
--- a/views/index.ejs
+++ b/views/index.ejs
@@ -82,7 +82,8 @@
<% if (!crontab.stopped) { %>
<% if (crontab.logging && crontab.logging != "false") {%>
-
+
+
<% } %>
Run
Edit