sa1eh
By:
sa1eh

How to run crontab for Magento upgrade

March 19, 2017 1.6k views
PHP DigitalOcean Ubuntu

I have Magento 2.0.7 and i want to upgrade to 2.1.5 which is the latest version of Magento but I'm having a problem with crontab when i try to upgrade the system and I do Readiness check it gives me a problem :

Example link

I tried this tutorial: http://devdocs.magento.com/guides/v2.0/comp-mgr/upgrader/upgrade-checklist.html

and i used these lines:

* * * * * /usr/bin/php /var/www/magento/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/magento/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/magento/update/cron.php >> /var/www/magento/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/magento/bin/magento setup:cron:run >> /var/www/magento/var/log/setup.cron.log```  

but it's not working
8 Answers

Which user are the cronjobs running under? What does /var/www/magento/var/log/magento.cron.log show?

  • What you mean by ( which user ) ?

    and how i can show this

    What does /var/www/magento/var/log/magento.cron.log show?

    • How did you set up the cronjobs?

      • Magento is installed in /var/www/html/magento

        and i used sudo crontab -e and i paste

        * * * * * /usr/bin/php /var/www/magento/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/magento/var/log/mage$
        * * * * * /usr/bin/php /var/www/magento/update/cron.php >> /var/www/magento/var/log/update.cron.log
        * * * * * /usr/bin/php /var/www/magento/bin/magento setup:cron:run >> /var/www/magento/var/log/setup.cron.log
        
        • What does tail -n 50 /var/www/magento/var/log/setup.cron.log say?

        • @sa1eh
          So you say Magento is installed in /var/www/html/magento, but all your contabs say it's installed in /var/www/magento
          Which is it?
          Try tail -50 /var/www/magento/var/log/setup.cron.log

it's in /var/www/html/magento

@hansen

i tried both /var/www/html/magento and /var/www/magento

I told you man before it's in /var/www/html/magento

@hansen

cat: /var/log/syslog: Permission denied
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command

* * * * * /usr/bin/php /var/www/html/magento/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/html/magento/var/log/mage$
* * * * * /usr/bin/php /var/www/html/magento/update/cron.php >> /var/www/html/magento/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/html/magento/bin/magento setup:cron:run >> /var/www/html/magento/var/log/setup.cron.log

this is the content of crontab

  • @sa1eh
    Which user are you doing this as?
    If you're missing permissions, then run at a higher level, such as root.
    So sudo cat /var/log/syslog

    • it's working now but it a huge log which part you would like me to show you?

      • Find one of the lines related to Magento.
        It starts with a date-time, then your hostname, then CRON[xxxx], then the first parentheses is the user, then CMD, and then the command.
        Which user is it running as? And does the command look correct?

        • Mar 22 15:04:01 Jakk-Store CRON[10356]: (magento) CMD (php /var/www/html/magento/update/cron.php &)
          Mar 22 15:04:01 Jakk-Store CRON[10355]: (magento) CMD (/usr/bin/php /var/www/html/magento/update/cron.php >> /var/www/html/magento/var/log/update.cron.log)
          Mar 22 15:04:01 Jakk-Store CRON[10354]: (magento) CMD (/usr/bin/php /var/www/html/magento/bin/magento setup:cron:run >> /var/www/html/magento/var/log/setup.cron.log)
          Mar 22 15:04:01 Jakk-Store CRON[10357]: (magento) CMD (php /var/www/html/magento/bin/magento setup:cron:run &)
          Mar 22 15:04:01 Jakk-Store CRON[10362]: (root) CMD (/usr/bin/php /var/www/html/magento/bin/magento setup:cron:run >> /var/www/html/magento/var/log/setup.cron.log)
          Mar 22 15:04:01 Jakk-Store CRON[10353]: (sa1eh) CMD (/usr/bin/php /var/www/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/magento/var/log/magento.cron.log)
          Mar 22 15:04:01 Jakk-Store CRON[10366]: (sa1eh) CMD (/usr/bin/php /var/www/magento/bin/magento setup:cron:run >> /var/www/magento/var/log/setup.cron.log)
          Mar 22 15:04:01 Jakk-Store CRON[10361]: (root) CMD (/usr/bin/php /var/www/html/magento/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/html/magento/var/log/mage$)
          Mar 22 15:04:01 Jakk-Store CRON[10369]: (root) CMD (/usr/bin/php /var/www/html/magento/update/cron.php >> /var/www/html/magento/var/log/update.cron.log)
          Mar 22 15:04:01 Jakk-Store CRON[10379]: (sa1eh) CMD (/usr/bin/php /var/www/magento/update/cron.php >> /var/www/magento/var/log/update.cron.log)
          
          • @sa1eh
            Okay, so you're running all the commands in 3 different crontab users.
            You probably want to only run it with magento, if that's your php and web server user for Magento.
            Magento is not a simple system to maintain. And it seems like you don't know the basics of Linux, which just makes it even more difficult. I would highly recommend that you hire someone to maintain it for you or use a service like Hypernode.

I know Linux basics but the problem i couldn't find a suitable tutorial on how to do it with clear examples

Good afternoon, I wanted to know if you had already solved the problem that you had with magento 2.0.7 and the upgrade, I also have the same problem. I would like to know if anyone can help us in this session or if we can make another decision about it.

Have another answer? Share your knowledge.