I am using a godaddy host. I already set the cron job command in the host php /home/site/laravel/artisan schedule:run
But the problem its returning this error for everytime it runs: [ErrorException]
Invalid argument supplied for foreach()
X-Powered-By: PHP/5.5.30
Content-type: text/html
Also it runs if i use the same artisan command in the ssh
Ok. I found the answer i had to use the command with the full path to the php like this: /usr/local/bin/php /home/mysitename/laravel/artisan schedule:run
Related
I have 7 projects working with:
QUEUE_DRIVER=database
in localhost everything working great when i open cmd and enter this
php artisan queue:work
and I uploaded it to my hosting
but I do not know how to wright cron job to do this
php artisan queue:work
my app path is public_html/faker
I found this code
/usr/bin/php /public_html/faker/artisan queue:work
but i have this error come to my email
Cron php /public_html/faker/artisan queue:work --queue=high,default
Status: 404 Not Found
Content-type: text/html; charset=UTF-8
No input file specified.
Can anyone right the code to me please?
I am using HMVC with codeigntier and try to run a cron job.
I am using this for the cron:
php /home/onlblcm/dev.mytranslator.com/index.php mytranslator cron cronTranslations > aaa.txt 2>&1
When running this from cron job, in aaa.txt file I get
Set-Cookie: ci_session=e56ef3d7d05652937b3269852d8b36eaeebba9a2; expires=Wed, 05-Sep-2018 13:39:26 GMT; Max-Age=7200; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Refresh:0;url=http/http/user/login
Content-type: text/html; charset=UTF-8
So it's super strange for me.
If I run the exact same command
php /home/onlblcm/dev.mytranslator.com/index.php mytranslator cron cronTranslations > aaa.txt 2>&1
From Putty (ssh) I get what I need. The file runs good. I get the desired output.
So it's the exact same command, but with CRON it fails.
I checked to see in SSH, and I am using user onlblcm
I checked the cron, and it's using the same user: onlblcm
So what can be the problem?
EDIT1:
I added -f in front of the index.php and I now get the error output:
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 284
<p>Backtrace:</p>
<p style="margin-left:10px">
File: /home/onlblcm/dev.mytranslator.com/application/third_party/MX/Loader.php<br />
Line: 173<br />
Function: _ci_load_library </p>
<p style="margin-left:10px">
File: /home/onlblcm/dev.mytranslator.com/application/third_party/MX/Loader.php<br />
Line: 192<br />
Function: library </p>
<p style="margin-left:10px">
File: /home/onlblcm/dev.mytranslator.com/application/third_party/MX/Loader.php<br />
Line: 153<br />
Function: libraries </p>
<p style="margin-left:10px">
File: /home/onlblcm/dev.mytranslator.com/application/third_party/MX/Loader.php<br />
Line: 65<br />
Function: initialize </p>
<p style="margin-left:10px">
File: /home/onlblcm/dev.mytranslator.com/application/modules/admin/controllers/Admin.php<br />
Line: 8<br />
Function: __construct </p>
As you can see, it's going to: /home/onlblcm/dev.mytranslator.com/application/modules/admin/controllers/Admin.php
But that has no sense, since I am not calling my admin controller.
Again, if I call the command from SSH it's working, from CRON is messed up.
EDIT 2:
I added to cron jobs this command:
php -f /home/onlblcm/dev.blasteronline.com/index.php > az.txt 2>&1
I get the exact same thing (error) when calling from Cron Job.
If I call it from SSH I get no output.
if I call from cron, I get the error like above.
EDIT 3:
I now managed to get the same error when using Putty/sssh.
If I run the command (ssh) with
php ....
It runs good
If I run the command (ssh) with:
/usr/bin/php
I get the same error like in cron.
With cron I tested with php ... and /usr/bin/php ... and I get the same error.
So somehow php is different than /usr/bin/php .
But I outputed the phpinfo and it's the same version.
When I use php info (via ssh) and use php I get a 32KB file with information (not html formated). When I use /usr/bin/php calling a file with php info, I get a file with 94K info (it is html formatted).
What is happening? Any ideas?
EDIT 3: SOLVED
It seems somehow the cron was calling a different PHP (although same version).
From Putty (ssh) I did a "whereis php"
I found 2 folder: /usr/bin/php AND /usr/local/bin/php
It seems calling simple php or /usr/bin/php FAILED the cron
When calling the cron with /usr/local/bin/php IT WORKS
Thanks
Hello and thanks in advance,
I am using Laravel 5 hosted on Godaddy. I am trying to get a cron job to run but I keep getting this message:
Status: 404 Not Found
X-Powered-By: PHP/7.1.11
Content-type: text/html; charset=UTF-8
No input file specified.
I haven't done a cron myself in Laravel before and I decided to follow this tutorial https://scotch.io/#Kidalikevin/how-to-set-up-cron-job-in-laravel
Everything works fine when I run php artisan DeleteInActiveUsers:deleteusers but the Cron doesn't.
Below are the commands I have tried in the Cron, the file name I created based on the tut is called DumpZohoContacts.php.
Note: I have added /usr/bin/php & -q but it still doesn't work I also ran app_path(); to see my app path and check that. And the code is not the issue since it runs fine by itself
Cron Commands:
php /home/[hidden]/public_html/rms/artisan schedule:run
php /home/[hidden]/public_html/artisan schedule:run
php /home/[hidden]/public_html/rms/artisan zohoDumpToDb:dumpContacts
php /home/[hidden]/public_html/artisan zohoDumpToDb:dumpContacts
php /home/[hidden]/public_html/rms/app/Console/Commands/artisan schedule:run
php /home/[hidden]/public_html/rms/app/Console/Commands/artisan zohoDumpToDb:dumpContacts
php /home/[hidden]/public_html/rms/app/Console/Commands/DumpZohoContacts.php
From my Email, I used to get this warning. Iff you have entered an incorrect command
PHP Warning: Module 'magickwand' already loaded in Unknown on line 0
Status: 404 Not Found
X-Powered-By: PHP/5.6.37
Content-type: text/html; charset=UTF-8
No input file specified.
If you are about to schedule the command as once a day (i.e., 00:00) the same time should be reflected in a $schedule->command(); object
In Kernel.php you should specify
/**
* Define the application's command schedule.
*
* #param \Illuminate\Console\Scheduling\Schedule $schedule
* #return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('SyncAPIOrders:orders')
->timezone('Asia/Kolkata')
->dailyAt('00:00');
}
You should add the command from the cPanel server as
/usr/local/bin/php /home/xyz/public_html/artisan schedule:run 1>> /home/xyz/public_html/log_laravel 2>&1
This will keep all the logs in /home/xyz/public_html/log_laravel
Running scheduled command: '/opt/cpanel/ea-php71/root/usr/bin/php' 'artisan' SyncAPIOrders:orders > '/dev/null' 2>&1
I have a Laravel 5.4 app which is on shared hosting and the cron job isn't working. I have set the command up in the kernel.php like so:
$schedule->command('eoddsmaker:get_events')
->withoutOverlapping()
->appendOutputTo(storage_path('logs').'/cron-get_events.log')
->everyMinute();
And if I just run /usr/bin/php-5.6 artisan eoddsmaker:get_events from the command line it runs fine. When it gets called by the cron job though it doesn't run. This is my cron definition:
* * * * * /usr/bin/php-5.6 /var/sites/c/cyo.mydomain.com/artisan schedule:run >> /var/sites/c/cyo.mydomain.com/cron.log 2>&1
I can see from the cron logs on the server that this task is running every minute and everytime that it runs the following output gets added to the cron.log file:
Running scheduled command: '/usr/bin/php' 'artisan' eoddsmaker:get_events > '/dev/null' 2>&1
X-Powered-By: PHP/5.6.8
Content-type: text/html; charset=UTF-8
So to dig a bit deeper if I look in the cron-get_events.log file that I have configured the task to send output to the following gets output every time it runs:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /var/sites/c/cyo.mydomain.com/artisan on line 31
Parse error: syntax error, unexpected T_STRING in /var/sites/c/cyo.mydomain.com/artisan on line 31
Because I'm on shared hosting the default PHP version is 5.2 and I have to add a rule in the htaccess file to get it to use PHP 5.6. If I forget to add the rule I get the same error as the one that is in the cron-get_events.log so this leads me to believe that the reason the command isn't working is because when the scheduler runs it is calling the command with /usr/bin/php as the path to PHP rather than /usr/bin/php-5.6
Is there a way to configure the task scheduler to use a different path to PHP?
I've managed to solve the problem by changing my scheduler task definition from:
$schedule->command('eoddsmaker:get_events')
->withoutOverlapping()
->appendOutputTo(storage_path('logs').'/cron-get_events.log')
->everyMinute();
To:
$schedule->exec('/usr/bin/php-5.6 /var/sites/c/cyo.mydomain.com/artisan eoddsmaker:get_events >> /var/sites/c/cyo.mydomain.com/cron.log 2>&1')
->withoutOverlapping()
->appendOutputTo(storage_path('logs').'/cron-get_events.log')
->everyMinute();
I'd still be interested to know through if there is a nicer way to achieve this so that I can just declare the path to PHP within Laravel
I ran into this problem as well today and was able to fix it by simply including
PHP_BINARY=/usr/bin/php
in the .env file.
I try to plan one-time job with 'at' command. There is next code in script:
$cmd = 'echo "/usr/bin/php '.$script_dir.$script_name.' '.$args.'"|/usr/bin/at "'.$time.'" 2>&1';
exec($cmd, $output , $exit_code);
When I run this command from script it adds the job to the schelude. This I see by the line in logs job 103 at Thu Sep 3 15:08:00 2015 (same text contains $output). But then nothing happens in specified time like at ignores the job. And there are no error messages in logs.
When I run same command with same args from command line on server it scheludes the job and than runs it at specified time.
I found out that when I try to plan a job via php script it runs under apache user. I tried to run next in command line on server:
sudo -u apache echo "/usr/bin/php /var/www/pant/data/www/pant.com/scripts/Run.php firstarg secondarg "|/usr/bin/at "16:00 03.09.2015"
It works correct too. I checked sudoers and have added apache user with NOPASSWD privileges. Script Run.php has execute rights.
at.deny is empty. at.allow does not exist.
So question is: why 'at' does not run command given via php script (exec) but runs same command in command line? How to run it?
Thanks to all.
I found by chance answer at stackexchange.com:
The "problem" is typically PHP is intended to run as module in a webserver. You may need to install the commandline version of php before you can run php scripts from the commandline