You could do every 24 hours like this, every 23 hours would be a little trickier.
<cron_expr>0 23 * * *</cron_expr>
Technically the syntax for every something somethings would be */something
, so */23
in your case.
Ie. If you wanted a cron to run every 6 hours, exactly on the hour, it would be,
<cron_expr>0 */6 * * *</cron_expr>
But this expression is only going to be valid for values under 12, as the cron's interpretation of 'every' resets each day.
So for every 23 hours, on the hour, you would be best executing it every hour like so, and doing a modulus of 23 within your script itself.
<cron_expr>0 * * * *</cron_expr>
Then in the method being executed, place this at the start,
$time = time();
if (((($time - ($time % 3600))/3600) % 23) != 0)
return;
Configure Magento cron job scheduler
By defining <schedule>
in crontab.xml, you're setting up periods when Magento should schedule that process.
To be able to schedule a job, you have to run Magento Cron scheduler - and that's what you did.
But, if you want to run your cron job in defined period continuously, you'll have to configure Magento Cron scheduler to be run in the background.
In order to do that, you'll have to insert following lines into your cron.
* * * * * <path to php binary> <magento install dir>/bin/magento cron:run
* * * * * <path to php binary> <magento install dir>/update/cron.php
* * * * * <path to php binary> <magento install dir>/bin/magento setup:cron:run
<path to php binary>
most often is /usr/bin/php5 (you can find it by typing "whereis php5" or "whereis php" in command line).
<magento install dir>
is path of your Magento instance.
More information how to set cron jobs can be found at http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html.
Background on Magento cron jobs implementation:
There are cron jobs defined at the system level, and they can be considered as real cron jobs. You can check those cron jobs by typing "crontab -e" in the command line for the current user.
On the other side, Magento offers the sophisticated configuration of cron jobs, but they are not "real" cron jobs. They are all invoked programmatically through one real cron job, by executing "bin/magento cron:run".
So, when you execute:
* * * * * <path to php binary> <magento install dir>/bin/magento cron:run
this is what is happening in Magento cron job scheduler (pseudo-code):
...
// runs all scheduled jobs (until limit is reached, configurable in Magento Admin)
foreach ($pendingCronJobs as $_job) {
$_job->run();
}
// generate new schedules for upcoming cron jobs
$this->generateNewSchedule();
// clean up old entries
$this->cleanUpOldEntries();
...
If you want to check more thoroughly how it looks behind the scenes, check Magento\Cron\Observer\ProcessCronQueueObserver, method execute()
Cron job groups
As you can see from Magento\Cron\Observer\ProcessCronQueueObserver, all scheduled cron jobs will be executed sequentially, one by one. It means that cron job (which is in "execution" state) will block the others from being executed until it's finished.
This can make troubles, especially if you have some long running cron jobs.
Magento2 offers the possibility to configure different groups for cron jobs. On that way, you can split cron jobs by putting long-running cron job into separate group(s).
More information about cron groups can be found at:
devdocs.magento.com/guides/v2.0/config-guide/cron/custom-cron-ref.html
Best Answer
Try
0 0,4,8,12,16,20 * * *
Note, if you do not see the cron in the table, it's not an error, because the scheduler creates the record with some delay.