How can i set up magento cron properly on shared hosting servers, where execution is prohibited via SSH?
i.e Setting up using crontab doesn't work. The temporary solution i have is the following:
*/10 * * * * php public_html/bin/magento cron:run
*/15 * * * * php public_html/bin/magento cache:clean
*/5 * * * * php public_html/bin/magento indexer:reindex
I have inserted these into the cron job section in cpanel.
This is probably a hideous way of tackling this problem, but atleast indexers are reindexed automatically right now. But when the site goes public, this needs to be set up correctly.
Running Magento 2.1.17
Your cron task for the scheduler is fine, but the other two are a bit weird.
Why do you need to clear your cache & reindex so often ?
Related
I cant get the Cron Job set up on our server to send out password resets and email confirmations. Have I set it up correctly? Have tried many different ways - the latest being:
curl -L -s http://www.****.com/cron.php
*/5 * * * *
Is this right? Ideally I'd like to set it to instant for now so I can see if is working, then change to every 5 minutes.
Update: I've been told by our server provider it has been set up properly, so is there anything within Magento I should check?
Thanks.
I am new with laravel. I need to send email every day, for example - at 10pm. I know how to send email, but I can't figure out, how to send this email, or lunch my email sending function every day, at specific time.
This probably isn't as much to do with Laravel as it is a task scheduler.
Check out Crontab for running scripts on a schedule
http://crontab.org
For running a job every day at 1pm Monday through Friday.
0 13 * * 1-5 $HOME/scripts/weekday_email.php
Laravel does have a 'later' method for the Mail class, but it won't send email repeatedly.
Mail::later(5, 'emails.welcome', $data, function($message)
{
$message->to('foo#example.com', 'John Smith')->subject('Welcome!');
});
http://laravel.com/docs/mail
The best way to do this in laravel is to build an artisan command, and then call that command via a cron job like so:
1 * * * * /path/to/php /path/to/app/artisan command:name
This allows you to easily test the cron by running the command directly in the terminal. Apart from that, using Laravel artisan commands means that you don't have to worry about autoloading all the classes necessary to execute the command - Laravel will handle that for you.
php artisan command:name
I have configured the LDAP authentication and added /auth/ldap/cli/sync_users.php to the crontab as described in the official manual: http://docs.moodle.org/26/en/LDAP_authentication.
But with no luck the LDAP thingy seemed to be failing to work properly. I believe the cron job has been set up properly, so I suppose I may have made some mistakes, or not providing enough information in the configuration for the LDAP authentication plugin.
As the cron script must be called from the command line, and I only have access to the FTP and MySQL database on the server, I have no idea how to execute the file to check if there are any errors (for debugging purpose).
So, I would like to know the proper way(s) to debug the LDAP authentication.
Please let me know if I am not making it clear enough. I could provide more details if needed.
Thank you.
UPDATES * * * *
I have tried to run the /admin/cron.php on a browser, and I have found the following lines in the output.
Running auth crons if required...
... started 10:24:18. Current memory use 27.9MB.
Does it have anything to do with the LDAP authentication? And what does it imply here?
Have you got something like this in your cron?
*/15 * * * * /usr/bin/php /path/to/moodle/auth/ldap/cli/sync_users.php >/dev/null
You could probably redirect the output to a log file to see whats going on.
*/15 * * * * /usr/bin/php /path/to/moodle/auth/ldap/cli/sync_users.php > /path/to/home/ldaperrors.log 2>&1
Also try it with debugging - add these to the config.php - not on a production site though, otherwise your users might see lots of errors.
#error_reporting(E_ALL | E_STRICT);
#ini_set('display_errors', '1');
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;
For those who stumble upon this via a search...
In Moodle 3.0 and above, cron jobs can be viewed and run from Site Administration>Server>Scheduled Tasks.
Very useful to view output of the task (in this case the LDAP authentication).
I have problems setting up a cron using CodeIgniter. I've followed the documentation and set up a test cron
* * * * * php /home/USERN/public_html/spider/index.php tools message
But this doesn't work. The output is just the index.php default controller, and not tools/message. When I run it in the terminal on the server, I get the results that I expect. Is there something I am doing wrong, or do I need to change something on the server?
For cPanel servers, in order to for CI to use the URI segments right, You'll have to use
/usr/local/bin/php
I have an MVC architecture and since I already have an action that would be extra useful if automatically called every hour or so, I wondered if there's a way to set it up as a cron job?
Don't know how periodic web page request is related to mvc, but you can achieve this by adding following line to crontab (1 hour period):
0 0/1 * * * wget <web_page_url>
Which is translated to: use wget command to request <web_page_url> every hour at zero minutes.
You can use
curl http://example.com
Or if the language you're using has a CLI client like PHP you could just run the script like
php /var/www/example.com/index.php
Edit:
For an MCV app it's probably easiest to use curl