Search code examples
phpcommand-linecronexecute

Can't execute command from crontab?


I want to update some stuff in my database everyday at 16:00.

So I use crontab which execute command which run my file.php which run the update. It works perfectly when I execute the command in the bash but There is a problem with the crontab.

crontab:

00 16 * * * ./etc/cron.daily/maj_cat

maj_cat

php var/www/dev/update.php

Thanks!


Solution

  • ./etc/cron.daily/maj_cat is a relative path, and var/www/dev/update.php too, try:

    00 16 * * * /etc/cron.daily/maj_cat
    

    and maj_cat:

    php /var/www/dev/update.php
    

    To you can do:

    00 16 * * * /usr/bin/env php /var/www/dev/update.php