Cron
Bash Environment Configuration
~/.bashrc.d/env
export PS1="\[\e[0;38;05;15m\][\[\e[0;38;05;47m\]\u\[\e[0;38;05;15m\]@\[\e[0;38;05;153m\]\h:\[\e[0;38;05;111m\]\w\[\e[0;38;05;15m\]]\\$ \[\e[0m\]"
alias m2-clean='rm -Rf generated/* var/cache/* var/page_cache/* var/di/* var/view_preprocessed/* pub/static/* && redis-cli FLUSHALL'
alias m2-cssclean="rm -Rf var/view_preprocessed/* && find pub/static/ -name 'styles-*.css' -exec rm -f {} \;"
alias m2-translation-clean="find pub/static/ -name 'js-transl*.*' -exec rm -f {} \; && php bin/magento cache:clean translate"
export PATH="$HOME/bin:$PATH"
Run cron as standalone process:
php bin/magento cron:run --group=default --bootstrap=standaloneProcessStarted=1
Debug Cron Job
TRUNCATE `cron_schedule`;
INSERT INTO `cron_schedule` (`job_code`, `status`, `messages`, `created_at`, `scheduled_at`, `executed_at`, `finished_at`) VALUES
('lengow_connector_launch_export', 'pending', NULL, NOW(), NOW(), NULL, NULL);
php bin/magento cache:clean
php bin/magento cron:run --group=default --bootstrap=standaloneProcessStarted=1
Reindex invalid indexers (full reindex of invalid indexers)
TRUNCATE `cron_schedule`;
INSERT INTO `cron_schedule` (`job_code`, `status`, `messages`, `created_at`, `scheduled_at`, `executed_at`, `finished_at`) VALUES
('indexer_reindex_all_invalid', 'pending', NULL, NOW(), NOW(), NULL, NULL);
php bin/magento cron:run --group=index --bootstrap=standaloneProcessStarted=1
Reindex of subscribed records of idle indexers
TRUNCATE `cron_schedule`;
INSERT INTO `cron_schedule` (`job_code`, `status`, `messages`, `created_at`, `scheduled_at`, `executed_at`, `finished_at`) VALUES
('indexer_update_all_views', 'pending', NULL, NOW(), NOW(), NULL, NULL);
php bin/magento cron:run --group=index --bootstrap=standaloneProcessStarted=1
Statistics
SELECT date(scheduled_at),
count(schedule_id) AS cnt,
SUM(IF(executed_at IS NULL, 0, 1)) as executed,
SUM(IF(finished_at IS NULL, 0, 1)) as finished
FROM `cron_schedule`
GROUP BY date(scheduled_at)
ORDER BY `scheduled_at` DESC;