Crontab not running in custom LAMP
-
I want to let the user configure custom cron jobs. What's the best approach to run crond in the container automatically?
-
You can check the mautic package (https://git.cloudron.io/cloudron/mautic-app) how to run crond via supervisor. But any reason not to use https://docs.cloudron.io/apps/#cron ?
-
Well, I understand that cron is already configured from what I see in the docs:
Cron jobs required for the app to function are already integrated into the app package and no further configuration is required. If you want to run additional custom cron commands, you can add them in the Cron section.
The thing is that jobs are not running. I'm not sure if I deleted something important from the Dockerfile or if I need anything else to make cron work. This is how I added a job:
-
@alex-uxlabsmx cron support comes from the platform code and should not be related to the packaging. Can you try the cron job in some other app ? (just the echo, remove the python stuff) . That way, we can figure if this is an app level issue or platform level.
-
We have several Apps running cron jobs without any problem. It must be an app level issue. The following screenshots are from another App running a cron job:
-
Only the cron job of running and healthy apps are run i.e it responds to health checks and this will result in dashboard saying 'Running'. Is that the case with the app? If so, I can't quite make out. Do you have a test repo for us where we can build it ourself?
-
Sorry I forgot about this. I haven't solved this issue yet. Yes, the case you mention is correct; health checks are okay and it says Running. Crons are just not working at all. This is the repo https://github.com/alex-uxlabs/demo-lamp
-
I ran this command but it's still is not working. I tried running the commands in my cron manually and they're working fine. The only problem is that Cron is not executing anything. I'm not sure if a specific version of PHP is needed since I removed all except 8.1
-
@alex-uxlabsmx I am afraid you have to contact support@cloudron.io at this point, out of ideas Have to debug the server.
-
@alex-uxlabsmx should work now. there were a couple of issues in the crontab:
- '&' in the end of the cron line. this puts the command in the background. cronjobs are not run in background and instead run on a schedule. so, the '&' should be removed.
- 'source' command is a bash primitive. you have to wrap it in bash -c "source ... && anothercommand", for example
seems to work after that.