Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codes don't work? #78

Open
garsamba opened this issue Feb 24, 2019 · 16 comments
Open

codes don't work? #78

garsamba opened this issue Feb 24, 2019 · 16 comments

Comments

@garsamba
Copy link

garsamba commented Feb 24, 2019

Im trying to use following code but it never worked for me. Is it possible to you help me to find my problem in this code ?

<?php
require_once __DIR__.'/vendor/autoload.php';

use GO\Scheduler;

$scheduler = new Scheduler();

$scheduler->php('test.php')->everyMinute();

$scheduler->run();

?>
@peppeocchi
Copy link
Owner

Hi @garsamba do you get any error back?
For starter did you check the path to your autoloader?
Did you also check the path to your test.php?
Can you also check the php binary? Are you on linux?
Did you setup correctly your crontab?
What happens if you run your scheduler file directly
php scheduler.php (assuming your scheduler file is called scheduler.php

I would start by debugging the above, you can add a file_exists function at the bottom, like

var_dump(file_exists(__DIR__.'/vendor/autoload.php'));
var_dump(file_exists('test.php'));

and then manually execute the scheduler, if you get false it means your paths are wrong.
I would also run a which php in your command line to see the exact PHP bin path.
And then if everything is ok and you're able to manually execute the scheduler, I would check that the crontab is set up correctly with crontab -l

Hope this helps

@garsamba
Copy link
Author

var_dump(file_exists(__DIR__.'/vendor/autoload.php')); var_dump(file_exists(__DIR__.'/test.php'));

Results: bool(true) bool(true)

I'm renewing the page manually but I can't get any results.

@rafaelmb
Copy link

are you running your scheduler with cron?

@garsamba
Copy link
Author

are you running your scheduler with cron?

i tried both, page refresh and https://cron-job.org/ crontab, but I didn't get the result

@rafaelmb
Copy link

did you try your local crontab file? Don't know if scheduler have some limitation on running via web.

@garsamba
Copy link
Author

did you try your local crontab file? Don't know if scheduler have some limitation on running via web.

yes test.php file is processing when I refresh it manually

@garsamba
Copy link
Author

did you try your local crontab file? Don't know if scheduler have some limitation on running via web.

Would you like to check with teamviewer?

@rafaelmb
Copy link

Your scheduler (calling test.php each minute) run using your cron file? Just following the project's front page instructions? Try this (not refreshing a page) to see if it works.

@garsamba
Copy link
Author

Programlayıcınız (her dakika test.php'yi çağırarak) cron dosyanızı kullanıyor mu? Sadece projenin ön sayfa talimatlarını takip ediyor musun? Çalışıp çalışmadığını görmek için bunu deneyin (sayfayı yenilemeyin).

yes using -> https://prnt.sc/mpu3hs

@rafaelmb
Copy link

I see. That is not using the crontab file, this is using an external service. You could as well call test.php straight from cron-job.org I don't know if scheduler is designed to work with this. Maybe @peppeocchi quem shed some light on this.

@garsamba
Copy link
Author

Your scheduler (calling test.php each minute) run using your cron file? Just following the project's front page instructions? Try this (not refreshing a page) to see if it works.

Why do we need to do a cron, page refresh?

@garsamba
Copy link
Author

Hi @garsamba do you get any error back?
For starter did you check the path to your autoloader?
Did you also check the path to your test.php?
Can you also check the php binary? Are you on linux?
Did you setup correctly your crontab?
What happens if you run your scheduler file directly
php scheduler.php (assuming your scheduler file is called scheduler.php

I would start by debugging the above, you can add a file_exists function at the bottom, like

var_dump(file_exists(__DIR__.'/vendor/autoload.php'));
var_dump(file_exists('test.php'));

and then manually execute the scheduler, if you get false it means your paths are wrong.
I would also run a which php in your command line to see the exact PHP bin path.
And then if everything is ok and you're able to manually execute the scheduler, I would check that the crontab is set up correctly with crontab -l

Hope this helps

i tried these codes on another server which is installed php version 5.4.45. Codes are working great there. Do you think this script doesnt work on my server because my php version is 7.0.33 ?

@peppeocchi
Copy link
Owner

@garsamba I don't think that's the issue, the code is tested against php 7.0, 7.1 and 7.2

I believe you have different configurations on the two servers? Can you schedule to run a simple Closure? And then run php scheduler.php
Did you check your system log files?

I would also compare the php .ini files between the two servers.

@garsamba
Copy link
Author

@garsamba I don't think that's the issue, the code is tested against php 7.0, 7.1 and 7.2

I believe you have different configurations on the two servers? Can you schedule to run a simple Closure? And then run php scheduler.php
Did you check your system log files?

I would also compare the php .ini files between the two servers.

i compared both php.ini and there is no huge difference. i fixed different functions and its still doesnt work. also i dont have any log in server log files about it.
My cpanel licence key expired this month do you think it can be because of it ?

@adamz01h
Copy link

in your cron try
* * * * * /usr/bin/php -f path/scheduler.php 1>> /dev/null 2>&1
then in scheduler.php at the top add
chdir(__DIR__)
post back results

@alex-monte
Copy link

I comment on my experience:
Calling scheduler.php via web browser doesn't work, you have to run scheduler.php script via command line for it to work properly. For exemple:
linux -> /usr/bin/php scheduler.php
xampp -> D:/xampp/php/php.exe scheduler.php

Also if you use xampp you have to refine the consistent PHP_BINARY with your php binary at the beginning of your scheduler.php script. For example:
define(PHP_BINARY, "D:/xampp/php/php.exe");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants