Skip to content

Commit ce242d0

Browse files
authored
Merge pull request pterodactyl#1143 from pterodactyl/feature/cron-job-fix
Fix cron jobs by removing the extra unusable argument
2 parents 5f6ee45 + ba96829 commit ce242d0

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

app/Services/Schedules/ProcessScheduleService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function handle(Schedule $schedule)
6363
{
6464
$this->repository->loadTasks($schedule);
6565

66-
$formattedCron = sprintf('%s %s %s * %s *',
66+
$formattedCron = sprintf('%s %s %s * %s',
6767
$schedule->cron_minute,
6868
$schedule->cron_hour,
6969
$schedule->cron_day_of_month,

app/Services/Schedules/ScheduleCreationService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function handle(Server $server, array $data, array $tasks = [])
8686
*/
8787
private function getCronTimestamp(array $data)
8888
{
89-
$formattedCron = sprintf('%s %s %s * %s *',
89+
$formattedCron = sprintf('%s %s %s * %s',
9090
array_get($data, 'cron_minute', '*'),
9191
array_get($data, 'cron_hour', '*'),
9292
array_get($data, 'cron_day_of_month', '*'),

app/Services/Schedules/ScheduleUpdateService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function handle(Schedule $schedule, array $data, array $tasks): Schedule
9898
*/
9999
private function getCronTimestamp(array $data)
100100
{
101-
$formattedCron = sprintf('%s %s %s * %s *',
101+
$formattedCron = sprintf('%s %s %s * %s',
102102
array_get($data, 'cron_minute', '*'),
103103
array_get($data, 'cron_hour', '*'),
104104
array_get($data, 'cron_day_of_month', '*'),

tests/Unit/Services/Schedules/ProcessScheduleServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testScheduleIsUpdatedAndRun()
6060

6161
$this->repository->shouldReceive('loadTasks')->with($model)->once()->andReturn($model);
6262

63-
$formatted = sprintf('%s %s %s * %s *', $model->cron_minute, $model->cron_hour, $model->cron_day_of_month, $model->cron_day_of_week);
63+
$formatted = sprintf('%s %s %s * %s', $model->cron_minute, $model->cron_hour, $model->cron_day_of_month, $model->cron_day_of_week);
6464
$this->repository->shouldReceive('update')->with($model->id, [
6565
'is_processing' => true,
6666
'next_run_at' => CronExpression::factory($formatted)->getNextRunDate(),

tests/Unit/Services/Schedules/ScheduleCreationServiceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testScheduleWithNoTasksIsCreated()
6464
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
6565
$this->repository->shouldReceive('create')->with([
6666
'server_id' => $server->id,
67-
'next_run_at' => CronExpression::factory('* * * * * *')->getNextRunDate(),
67+
'next_run_at' => CronExpression::factory('* * * * *')->getNextRunDate(),
6868
'test_key' => 'value',
6969
])->once()->andReturn($schedule);
7070
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
@@ -85,7 +85,7 @@ public function testScheduleWithTasksIsCreated()
8585
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
8686
$this->repository->shouldReceive('create')->with([
8787
'server_id' => $server->id,
88-
'next_run_at' => CronExpression::factory('* * * * * *')->getNextRunDate(),
88+
'next_run_at' => CronExpression::factory('* * * * *')->getNextRunDate(),
8989
'test_key' => 'value',
9090
])->once()->andReturn($schedule);
9191

tests/Unit/Services/Schedules/ScheduleUpdateServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testUpdate()
6464

6565
$this->connection->shouldReceive('beginTransaction')->once()->withNoArgs();
6666
$this->repository->shouldReceive('update')->once()->with($schedule->id, array_merge($data, [
67-
'next_run_at' => CronExpression::factory('1 2 3 * 4 *')->getNextRunDate(),
67+
'next_run_at' => CronExpression::factory('1 2 3 * 4')->getNextRunDate(),
6868
]))->andReturn($schedule);
6969

7070
$this->taskRepository->shouldReceive('deleteWhere')->once()->with([['schedule_id', '=', $schedule->id]]);

0 commit comments

Comments
 (0)