0

Well I am trying to run my scheduler but it doesn't seem to do anything.

I have created this command

$schedule = new Schedule();
$schedule->command("hello:test_command 5")
    ->cron("13 12 * * *") //should run at 12:13, used as test time
    ->sendOutputTo("test_data.txt");

I tried running the scheduler both automatically and manually but there's nothing from the commands themself...

When I run scheduler:run this is what I get

Running scheduled command: "C:\xampp_7\php\php.exe" "artisan" hello:test_command > "NUL" 2>&1

I am running it on windows 10 and PHP 7.3 if it matters at all.

Also, test_data.txt is not being created at all.

EDIT: Just to add up, after some testing, it seems that it's not even adding the command to the schedule...

Tommy
  • 3
  • 3
  • I could not do this either, either Laravel, and I made this job cronjob definition to the last resort control panel. – Yunus Kocabay Jan 11 '21 at 12:27
  • Make sure your system PHP time is the same as in your timezone. I had such situation and noticed that "date('H:i')" returns 2 hours less than was showed in my computer's clock. – VG-Electronics Jan 11 '21 at 12:48
  • @SentalPL Yeah, tried with that too. Same thing happens... I even tried scheduling for every minute of every hour but still I am getting the same output. I mean it's like it's not calling the argument or such? Not sure anymore... Is there a way to flush all pending commands? – Tommy Jan 11 '21 at 12:52
  • @Tommy In the line "$schedule->command("hello:test_command 5")" you've got "5" at the end. What it stands for? – VG-Electronics Jan 11 '21 at 13:11
  • @SentalPL it's just an additional parameter since the command itself requires it – Tommy Jan 11 '21 at 13:20
  • @Tommy Couldn't you add parameters like in this question - https://stackoverflow.com/questions/30202268/laravel-5-command-scheduler-how-to-pass-in-options? Unless I misunderstood this question and it's not such type of parameter. – VG-Electronics Jan 11 '21 at 13:31
  • @SentalPL yeah I could and should! :D Altho what I just noticed that adding $schedule->command under schedule() in Kernel.php works but when I do from a controller it doesnt.. – Tommy Jan 11 '21 at 13:35
  • @Tommy Hmm, I'm not sure if it's possible outside of Kernel class. Could you send some link which says it's possible? By the way, does changing a way of putting parameter solve the problem (when you put it in Kernel)? – VG-Electronics Jan 11 '21 at 13:41
  • @SentalPL oh shit :D thats the problem than! :D I was trying to dynamically add it outside the kernel :D I thought it's possible! :D – Tommy Jan 11 '21 at 13:42
  • @Tommy Great it's solved :) Can I add the answer to be accepted by you? – VG-Electronics Jan 11 '21 at 13:44
  • @SentalPL yep! Thanks! I will surely accept it! – Tommy Jan 11 '21 at 13:48

1 Answers1

0

Do you schedule this command inside Kernel class? It can't be used outside this file. Also I think that you should pass parameter this way:

$schedule->command("hello:test_command --yourparam=5")

Instead of:

$schedule->command("hello:test_command 5")
VG-Electronics
  • 230
  • 2
  • 16