I'm trying to run a cron in my OVH but it is not accepting the command :
php artisan schedule:run 1>> /dev/null 2>&1
Error occured :
it say :
The characters for the records are letters , numbers, and characters -_./ Moreover , it is forbidden to access parent folders
Use the example on the Laravel docs with the full path to your working directory:
* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
https://laravel.com/docs/master/scheduling
Create a file cron.php with these contents
#!/usr/bin/env php
<?php
exec('php /path/to/artisan schedule:run', $output);
print_r($output);
Make sure to edit the /path/to part. Then enter cron.php in "command to be executed" field in "Add a scheduling" window.
If you run into error, try checking permissions for cron.php and artisan. Permission can be fixed using these commands.
$ chmod 777 cron.php
$ chmod 777 /path/to/artisan
Just follow this answer
Related
I have made a command and scheduled it for every 30 minutes. When I run php artisan schedule:run it works perfectly fine and returns with the expected results, but when I configured it on my live server my cron job do run but instead of retuning the success message it returns with list of all available command in my laravel project. Here is what I am doing.
Command Kernel:
$schedule->command('update:callLogs')
->everyMinute();
Cron Entry:
/usr/bin/php /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/artisan schedule:run
And this is the response I am getting
Laravel Framework 5.8.38
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
(List of all availabe commands)
Any help will be much appreciated.
EDIT
Now my command looks like this
* * * * * cd /home/ddsas9rm2f1g/public_html/clowdlink.com/crm && php artisan update:callLogs
but getting the same response whereas when I copy the same command and using putty ran the same command and it works perfectly fine. Now it's been a week now and I'm still stuck at this cron thing.
I fixed this by specifying the path to PHP instead of using just php.
From this: cd /home/foobar && php artisan schedule:run
To this: cd /home/foobar && /usr/local/bin/php artisan schedule:run
This stopped me from getting a list of available artisan commands and gave me the right output.
I can see it looks like you've already tried that, but I think others will run into this too. I'd imagine your issue is something to do with the PHP version you're using not being able to properly run PHP scripts. Maybe an opcache thing with CLI?
I faced big challenge as well when I was deploying one my applications, and finally managed to tackle it with:
cd /path-to-project && /opt/cpanel/ea-php71/root/opt/cpanel/ea-php74/root/usr/bin/php-cgi artisan schedule:run
I use Laravel 5.7 for my application
You could try the following code:
* * * * * php /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/artisan schedule:run 1>> /dev/null 2>&1
>> /dev/null 2>&1: we will discard all output of a command.
Can you try the below in cron and share the output of crontab.out
* * * * * cd /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/ && php artisan schedule:run >> crontab.out 2>&1
*/30 * * * * php /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/artisan schedule:run 1>> /dev/null 2>&1
OR
*/30 * * * * /usr/bin/php /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/artisan schedule:run 1>> /dev/null 2>&1
OR
*/30 * * * * cd /home/ddsas9rm2f1g/public_html/clowdlink.com/crm && php artisan schedule:run >> /dev/null 2>&1
Also read full post: https://devnote.in/how-to-set-auto-database-backup-with-cron-scheduler-in-laravel/
The below cronjob is not working, although the task itself is working when I manually run it using php artisan q:calc .
I just added the path for php and artisan files as shown below, and pasted the command in the terminal.
Am I missing something ?
* * * * * /usr/bin/php /var/www/html/sharp/artisan schedule:run >> /dev/null 2>&1
That command is a cron entry, not something you run in terminal.
For example, under the specific user you would run (depending on your environment):
$ crontab -e
And paste the above to the crontab file.
You can learn more in the docs:
https://laravel.com/docs/master/scheduling
Or by researching how to add cron entries for your specific operating system.
I have 7 different schedule commands on kernel.php and one of those is not firing when running the schedule.
kernel.php
....
$schedule->command('my:command')->hourlyAt(15); // this wont run
...
Running php artisan my:command manually on command line works fine.
Also when running the scheduler on our dev server, all commands works fine. The problem is only on production server.
There are no errors on log files.
Any ideas what might be wrong?
I'm using Laravel 5.6
UPDATED:
The problem was wrong artisan path on laravel forge scheduler
Have you add following cron entry as per your project folder path ?
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
please check with following commands
crontab -l
If not ?
open crontab by
crontab -e
add * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1 entry at the end of file
save file and run following commands
sudo service cron restart
again check with crontab -l
this command will return already set cronjob
i hope it helps :)
I'm have a laravel5.5 project up on shared hosting and trying to run cron job to execute the command "schedule:run" but it just won't execute I think I'm writing the command wrong:
/usr/local/bin/php home/schoolco/prototype/artisan schedule:run >> /dev/null 2>&1
where prototype in the name of my laravel project.
the command works in this directory using ssh.
please if you have any observation or thought share it.
Try like this
/usr/local/bin/php /home/schoolco/prototype/artisan schedule:run > /dev/null 2>&1
And check are you calling right php executable in your terminal with:
$ which php
Maybe it is not /usr/local/bin/php , maybe /usr/bin/php
If your Project is in Root Directory
cd /home/cpanel/public_html && /usr/local/bin/ea-php72 artisan schedule:run >> /dev/null 2>&1
If your Project in a folder within Public_Html then use below
cd /home/cpanel/public_html/folder_name && /usr/local/bin/ea-php72 artisan schedule:run >> /dev/null 2>&1
Hope it will work for you. Thanks
I solved the issue by specifying the php version in the command line:
* * * * * /usr/local/bin/ea-php71 /home/nemanu/root1/artisan schedule:run >> /dev/null 2>&1
I have been pulling my hair out for the past 5 hours over what I thought would be a simple task, enabling the cron feature for Laravel. I am running Laravel 5.1 on an Amazon EC2 Ubuntu LAPP stack server.
I have added the cron task to the cron jobs list using the command
sudo crontab -e
Then I have added the command listed in the laravel documentation
* * * * * php /home/bitnami/htdocs/project/app/artisan schedule:run >> /dev/null 2>&1
I have made sure that cron is running and I can see that the task is running if I run
sudo grep -i cron /var/log/syslog|tail -3
Which returns
Mar 4 15:36:01 ip-172-31-7-174 CRON[15120]: (root) CMD (php /home/bitnami/htdocs/project/app/artisan schedule:run >> /dev/null 2>&1)
Mar 4 15:37:01 ip-172-31-7-174 CRON[15123]: (root) CMD (php /home/bitnami/htdocs/project/app/artisan schedule:run >> /dev/null 2>&1)
Mar 4 15:38:01 ip-172-31-7-174 CRON[15125]: (root) CMD (php /home/bitnami/htdocs/project/app/artisan schedule:run >> /dev/null 2>&1)
I have tested that the path has not got any typos in it by running the command from the command line and it works properly
php /home/bitnami/htdocs/project/app/artisan schedule:run
Also I have added this cron task just to confirm that cron is actualy running
* * * * * echo "Cron" > /home/bitnami/htdocs/project/app/artisan/file.txt
I have also made sure the file is executable by doing the following but this has not fixed the issue either
chmod 755 artisan
chmod 777 artisan (I am aware this is dangerous)
chmod +x artisan (Suggested on fourms)
Does anyone have any suggestions where I'm going wrong here.
I've experienced this and found a solution. It's because of unknown reason in bitnami, so that php command not recognized by cron. I used this command to make it working :
* * * * * /path/to/php/bin/php /home/bitnami/htdocs/project/app/artisan schedule:run 1>> /dev/null 2>&1