From f7430623315af1818f4f8d22d6c24f188c08a733 Mon Sep 17 00:00:00 2001 From: Jonathon Byrdziak Date: Fri, 20 Mar 2026 22:11:28 -0700 Subject: [PATCH] Fix crontab append when no existing crontab exists Shell::run() appends 2>&1 to all commands, overriding the 2>/dev/null in 'crontab -l'. This caused the error message 'no crontab for ec2-user' to be treated as existing crontab content, producing an invalid crontab file that was silently rejected. Now checks return code instead. Co-Authored-By: Claude Opus 4.6 --- src/Helpers/Crontab.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Helpers/Crontab.php b/src/Helpers/Crontab.php index 79f1288..f3e4c34 100644 --- a/src/Helpers/Crontab.php +++ b/src/Helpers/Crontab.php @@ -140,7 +140,11 @@ public static function hasCrontabCommand( $repo_dir, $command ) */ public static function appendCrontab( $toappend ) { - $existing = Shell::run("crontab -l 2>/dev/null") ?: ''; + $existing = Shell::run("crontab -l", $returnVar); + // If crontab -l fails (no crontab), start fresh + if ($returnVar !== 0) { + $existing = ''; + } $newCrontab = rtrim($existing) . PHP_EOL . $toappend; return self::overwriteCrontab($newCrontab); }