kool-dev / kool

From local development to the cloud: web apps development with containers made easy.

Home Page:https://kool.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Laravel schedule cron

unisaless opened this issue · comments

Summary

Hello. I'm trying to run schedule:run with cron but nothing happends. Other commands are runnig well, but this don't. What am I doing wrong?


  • Ubuntu 20.04 (LTS) x64
  • Docker 20.10.8, build 3967b7d
  • Kool 1.14.0
* * * * * cd /path/to/project && kool run artisan schedule:run >> /dev/null 2>&1
$ sudo service cron status

cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-09-15 04:20:08 UTC; 30min ago
       Docs: man:cron(8)
   Main PID: 86481 (cron)
      Tasks: 1 (limit: 1136)
     Memory: 988.0K
     CGroup: /system.slice/cron.service
             └─86481 /usr/sbin/cron -f
$ sudo service docker status

docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-09-14 11:11:35 UTC; 17h ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 8413 (dockerd)
      Tasks: 35
     Memory: 52.6M
     CGroup: /system.slice/docker.service
             ├─8413 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
             ├─8772 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5432 -container-ip 172.19.0.3 -container-port 5432
             ├─8778 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 5432 -container-ip 172.19.0.3 -container-port 5432
             ├─8799 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.19.0.4 -container-port 80
             └─8805 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 80 -container-ip 172.19.0.4 -container-port 80
$ kool status

+----------+---------+---------------------------------------------+-----------------------+
| SERVICE  | RUNNING | PORTS                                       | STATE                 |
+----------+---------+---------------------------------------------+-----------------------+
| app      | Running | 0.0.0.0:80->80/tcp, :::80->80/tcp, 9000/tcp | Up 18 hours           |
| cache    | Running | 6379/tcp                                    | Up 18 hours (healthy) |
| database | Running | 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   | Up 18 hours (healthy) |
+----------+---------+---------------------------------------------+-----------------------+

Hey, hard to tell... maybe you need to add more logging to your cron to really see what's the problem, like changing the command to:

* * * * * cd /path/to/project && kool run artisan schedule:run >> /var/log/kool-cron.log 2>&1

So you can investigate....

One thing that might be causing problem is the user it's running in the cron... is it root? or a different user? does this user has access to docker?

Anyway, it feels it's not a problem on kool itself but on your cron setup.

Additional logging do nothing, 'cause of this job not running at all.
As a temp solution I added sudo to kool run artisan. But it's not ok

So it does seem a user / permission problem... hard to help without knowing the full picture... but again, things to look:

Kool file permission, maybe it's only executable to your user... check with ls -lah /usr/local/bin, what user did you add at cron? does this user can execute docker commands?

Try running manually kool with the cron user... also another thing that might help is adding kool info to a cron and writing it to a log to see if it gives some hints:

* * * * * cd /path/to/project && kool info >> /var/log/kool-cron.log 2>&1

Hello @unisaless - did you manage to make it work, figure out what was wrong with your crontab service?

As this doesn't seem to be a specific kool issue, instead of a system configuration issue, I am closing this issue.

Please feel free to reopen in case you think there is indeed an issue we could work on to solve, or simply register the outcome so others can benefit from whatever fixed it for you.