Article

How to successfully run drush commands from crontab?

After trying for a couple of hours to run cron from crontab I finally managed to make it. System logs helped me with that.

So, long story short, you need to add environment path in your cron table first line (cron commands run one after anonther). Like this:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Because I have drush in /usr/local/bin, I need to specifically add that in my path env. Also, you need to add the path where php binary file is.

To find out where a file is, just type which your-bin-file-here. Eg. which drush will give me /usr/local/bin/drush. Or which php gives me /usr/local/bin/php

Now your system cron will smoothly run every drush command.

Rate this article: 

Average: 4.2 (5 votes)

Category: 

 

Portfolio

Samples of work done for me or my customers, for free or not, like websites, repairs, photography etc.
View all my recent work

 

Tutorials

I'm giving away some knowledge in my areas of expertise. Did you like something here? Share it please!
View all tutorials

 

Snippets

Useful Linux commands or other code snippets I often use.
View my useful shortcuts

 

Resources

Few bookmarks I find useful. Do you want website here? Give me a good reason and I can help you.
View my favourite web resources

About me

Hi there! My name is Marius Cârneală.

About me?

Loving husband, dad of one two three, drone pilot, web designer and administrator, SEO specialist, IT support guy, electronic hobbyist and content writer. This list is open.