Update crontab call
This commit is contained in:
parent
d5e33d2a39
commit
bf754c79d6
@ -27,8 +27,7 @@ public class LinuxScheduler {
|
|||||||
try {
|
try {
|
||||||
String taskName = "numbers-station-main_" + settings.getName();
|
String taskName = "numbers-station-main_" + settings.getName();
|
||||||
|
|
||||||
// TODO: assume it's on the PATH
|
Process listProcess = new ProcessBuilder("crontab", "-l").start();
|
||||||
Process listProcess = new ProcessBuilder("/usr/bin/crontab", "-l").start();
|
|
||||||
if (!listProcess.waitFor(5, TimeUnit.SECONDS)) {
|
if (!listProcess.waitFor(5, TimeUnit.SECONDS)) {
|
||||||
String message = "Failed to query " + taskName + " task: process timed out";
|
String message = "Failed to query " + taskName + " task: process timed out";
|
||||||
logger.log(Level.SEVERE, message);
|
logger.log(Level.SEVERE, message);
|
||||||
@ -69,8 +68,7 @@ public class LinuxScheduler {
|
|||||||
|
|
||||||
String newCrontab = sb.toString();
|
String newCrontab = sb.toString();
|
||||||
|
|
||||||
// TODO: assume it's on the PATH
|
Process addProcess = new ProcessBuilder("crontab", "-").start();
|
||||||
Process addProcess = new ProcessBuilder("/usr/bin/crontab", "-").start();
|
|
||||||
Writer w = new OutputStreamWriter(addProcess.getOutputStream(), "UTF-8");
|
Writer w = new OutputStreamWriter(addProcess.getOutputStream(), "UTF-8");
|
||||||
System.out.println(newCrontab);
|
System.out.println(newCrontab);
|
||||||
w.write(newCrontab);
|
w.write(newCrontab);
|
||||||
@ -94,23 +92,6 @@ public class LinuxScheduler {
|
|||||||
return Results.failure(message);
|
return Results.failure(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path cronDPath = Paths.get("/etc/cron.d");
|
|
||||||
// if (!Files.exists(cronDPath)) {
|
|
||||||
// String message = "/etc/cron.d does not exist, cannot create cron entry. Select 'Manage schedule externally' and set up scheduling as desired.";
|
|
||||||
// logger.log(Level.SEVERE, message);
|
|
||||||
// return Results.failure(message);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Path cronPath = cronDPath.resolve(settings.safeName());
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// Files.write(cronPath, cronEntry(settings).getBytes(StandardCharsets.UTF_8));
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// String message = "Failed to write cron file at '" + cronPath.toString() + "'";
|
|
||||||
// logger.log(Level.SEVERE, message, e);
|
|
||||||
// return Results.failure(message);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return Results.success(true);
|
return Results.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user