DEV Community

Discussion on: Cron with Lando

Collapse
 
djboris88 profile image
Boris Đemrovski

Thank you! Very useful and easy to set up.

Collapse
 
djboris88 profile image
Boris Đemrovski

Actually, it doesn't start automatically after lando is restarted... :( I have to ssh manually and run service cron start for it to work after appservice restarts.

Collapse
 
djboris88 profile image
Boris Đemrovski

Ok, I managed to do it.

Here is @jcandan 's script but updated with an additional step:

appserver:
    build_as_root:
      - apt-get update -y
      - apt-get install cron -y
      - cp -f /app/.lando/docker-php-entrypoint.sh /usr/local/bin/docker-php-entrypoint
    run_as_root:
      - service cron start
    run:
      - crontab /app/resources/config/cron.txt
Enter fullscreen mode Exit fullscreen mode

The only thing added is the command to copy a changed docker entrypoint bash script to the usual place. And here is the content of the changed entrypoint script:

#!/bin/sh
service cron start

set -e

# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
        set -- apache2-foreground "$@"
fi

exec "$@"
Enter fullscreen mode Exit fullscreen mode

Here I only added service cron start, the rest was already there in the original entrypoint bash script. I actually used the same combo for getting the supervisor to work, for Laravel queue workers.