cancel
Showing results for 
Search instead for 
Did you mean: 

Cron jobs problem and general question

Cron jobs problem and general question

When I go to admin > system >marketplace I get the error:

 

Cron is not configured properly. Marketplace won't work without cron.

 

I would like to ask help to resolve this issue, but I also have a question in general.  A coder who was working on our site told me that "cron job for reindexing, it's not so critical, we can do it manually. Setting reindexing from cron jobs sometimes may take high cpu usage or it may increase db size automatically day by day".  I don't really understand what cron jobs is, so I don't know if this is good advice.

 

Thanks

3 REPLIES 3

Re: Cron jobs problem and general question

Hi @bigbob2 

Best way to setup cron job is command line as mentioned below.

1. Type

crontab -e 

2. Add the following lines to your crontab file:

*/1 * * * * php -c {php.ini_path} {magento_path}/bin/magento cron:run
*/1 * * * * php -c {php.ini_path} {magento_path}/update/cron.php
*/1 * * * * php -c {php.ini_path} {magento_path}/bin/magento setup:cron:run

example:

*/1 * * * * php -c /etc/php7.2/apache2/php.ini /var/www/m2/bin/magento cron:run
*/1 * * * * php -c /etc/php7.2/apache2/php.ini /var/www/m2/update/cron.php
*/1 * * * * php -c /etc/php7.2/apache2/php.ini /var/www/m2/bin/magento setup:cron:run

Save and close the crontab file.

If you face any memory exhaust issue. Add -dmemory_limit=6G with command as mentioned below:

*/1 * * * * php -c /etc/php7.2/apache2/php.ini -dmemory_limit=6G /var/www/m2/bin/magento  indexer:reindex

If issue resolve, please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

Re: Cron jobs problem and general question


@Bhanu Periwal wrote:

Hi @bigbob2 

Best way to setup cron job is command line as mentioned below.

1. Type

crontab -e 

2. Add the following lines to your crontab file:

*/1 * * * * php -c {php.ini_path} {magento_path}/bin/magento cron:run
*/1 * * * * php -c {php.ini_path} {magento_path}/update/cron.php
*/1 * * * * php -c {php.ini_path} {magento_path}/bin/magento setup:cron:run

example:

*/1 * * * * php -c /etc/php7.2/apache2/php.ini /var/www/m2/bin/magento cron:run
*/1 * * * * php -c /etc/php7.2/apache2/php.ini /var/www/m2/update/cron.php
*/1 * * * * php -c /etc/php7.2/apache2/php.ini /var/www/m2/bin/magento setup:cron:run

Save and close the crontab file.

If you face any memory exhaust issue. Add -dmemory_limit=6G with command as mentioned below:

*/1 * * * * php -c /etc/php7.2/apache2/php.ini -dmemory_limit=6G /var/www/m2/bin/magento  indexer:reindex

If issue resolve, please click on 'Kudos' & Accept as Solution!


I entered the first command you gave and it seemed to work, but it does not leave me with the Terminal cursor to enter the second command.  Sorry, I don't understand Cron Jobs, so I might be missing something obvious:

 

@Reboot /usr/local/cpanel/bin/onboot_handler
41 5 * * * /usr/local/cpanel/whostmgr/docroot/cgi/cpaddons_report.pl --notify
42 5 * * * (/usr/local/cpanel/scripts/fix-cpanel-perl; /usr/local/cpanel/scripts/upcp --cron > /dev/null)
0 1 * * * /usr/local/cpanel/scripts/cpbackup
0 2 * * * /usr/local/cpanel/bin/backup
35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check && /usr/local/cpanel/bin/tail-check
0 6 * * * /usr/local/cpanel/scripts/exim_tidydb > /dev/null 2>&1
30 5 * * * /usr/local/cpanel/scripts/optimize_eximstats > /dev/null 2>&1
5,20,35,50 * * * * /usr/local/cpanel/scripts/eximstats_spam_check 2>&1
45 */4 * * * /usr/bin/test -x /usr/local/cpanel/scripts/update_mailman_cache && /usr/local/cpanel/scripts/update_mailman_cache
30 */4 * * * /usr/bin/test -x /usr/local/cpanel/scripts/update_db_cache && /usr/local/cpanel/scripts/update_db_cache
25 */2 * * * /usr/local/cpanel/bin/mysqluserstore >/dev/null 2>&1
15 */2 * * * /usr/local/cpanel/bin/dbindex >/dev/null 2>&1
15 */6 * * * /usr/local/cpanel/scripts/autorepair recoverymgmt >/dev/null 2>&1
*/5 * * * * /usr/local/cpanel/scripts/dcpumon-wrapper >/dev/null 2>&1
0 */2 * * * /usr/local/cpanel/scripts/shrink_modsec_ip_database -x 2>&1
8,23,38,53 * * * * /usr/local/cpanel/whostmgr/bin/dnsqueue > /dev/null 2>&1
22 22 * * 7 /usr/local/cpanel/scripts/send_api_notifications > /dev/null 2>&1
09,39 * * * * /usr/local/cpanel/scripts/clean_user_php_sessions > /dev/null 2>&1
~
~
~
~
"/tmp/crontab.vP3YYP" 19L, 1444C

Re: Cron jobs problem and general question

Hello @bigbob2 

 

Magento did nice documation on this

 

https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-cron.html

 

hope you how to work vi commands on Linux

 

thanks

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer