I don't know what you are doing wrong but I can tell you how I set up Magento2 cron on a recent project.
I have been putting files inside the
/etc/cron.d/ folder. This may be specific to certain Linux distributions and may be specific to how a particular Linux box is set up.
But in theory any file inside the
/etc/cron.d/ folder will be run by cron. The syntax is slightly different but this method avoids having to work out which users' crontab to edit.
# File : /etc/cron.d/magento2
# Run Magento2 cron every 7 minutes
*/7 * * * * magento_user php /var/www/html/magento2/bin/magento cron:run
[Linux commands* to create the file are
ls -l will show you the files here already.
*you might prefer to type
nano magento2 instead of
nano being a slightly more user-friendly editor for those unaccustomed to editing text files in Linux
please note: add a blank line at the end of this text file after the cron entry so the file ends with an empty line (this may be superstition but there is no harm in it)
To check that cron is running, on the Linux command prompt enter:
grep CRON /var/log/syslog
if that fails (Linux setups vary in where cron logs to) try
tail -n 100 /var/log/cron
[if that fails, hit the internet for advice such as this from Benjamin Cane]
You should see some log entries from various cron jobs that are running. If you do not see any recent entries then perhaps the Linux cron is not running but I think that would be unusual (and a whole different Q&A).
Eventually you should see a Magento entry in your Linux cron log due to the file you put in
/etc/cron.d/ for example I see this:
CROND: (magento_user) CMD (php /var/www/html/magento2/bin/magento cron:run)
Then the main way I check Magento cron is behaving is to study the Magento database table
cron_schedule closely (using a tool such as MySQL Workbench).
If the Linux OS cron is calling Magento2 cron then you should see entries in this table with status
pending. Presently you should see status
complete or perhaps a useful error message to indicate where the Magento cron failed.
I re-read your question.
cron.php is from Magento 1.x so you should ignore any advice related to that
- if you want to log to
<magento install path>/var/log/some-cron-file.log then you do probably need to create that file first by
touch some-cron-file.log and then the harder part: give your new file the correct ownership and permissions for Linux cron to be able to write here. I don't know what they are for you but I know you can work that out. (but you don't really need to make your own log entries, the Linux system will most likely, and can be set to, log cron jobs to
syslog or a dedicated log file)