Update crontab call

This commit is contained in:
Nathan McRae 2025-05-26 21:50:45 -07:00
parent d5e33d2a39
commit bf754c79d6

View File

@ -27,8 +27,7 @@ public class LinuxScheduler {
try {
String taskName = "numbers-station-main_" + settings.getName();
// TODO: assume it's on the PATH
Process listProcess = new ProcessBuilder("/usr/bin/crontab", "-l").start();
Process listProcess = new ProcessBuilder("crontab", "-l").start();
if (!listProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to query " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
@ -69,8 +68,7 @@ public class LinuxScheduler {
String newCrontab = sb.toString();
// TODO: assume it's on the PATH
Process addProcess = new ProcessBuilder("/usr/bin/crontab", "-").start();
Process addProcess = new ProcessBuilder("crontab", "-").start();
Writer w = new OutputStreamWriter(addProcess.getOutputStream(), "UTF-8");
System.out.println(newCrontab);
w.write(newCrontab);
@ -94,23 +92,6 @@ public class LinuxScheduler {
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);
}