dokku / dokku

A docker-powered PaaS that helps you build and manage the lifecycle of applications
https://dokku.com
MIT License
29.31k stars 1.92k forks source link

Dokku cron job output is blank #451

Closed ghost closed 9 years ago

ghost commented 10 years ago

I am having some troubles writing a cron job on my server. This is the output of crontab -l for my root user. The command in quotes works perfectly when called from the command line - User.eodemail is a Model method I am running. The cron log gets overwritten with nothing (i.e. it is blank) at 6 AM. Any idea what is going on?

daviddias commented 10 years ago

I think that is because the default image of ubuntu in docker doesn't come with the cron daemon running.

Here is a great blog post explaining it - http://phusion.github.io/baseimage-docker/

It would be great if the dokku default image was this baseimage-docker to have this kind of things set up by default

plietar commented 10 years ago

@diasdavid He is running the cron job on the host. The job is running correctly, ie the log file gets overriden. The problem is with the output not written.

Moreover, I find this blog article wrong on many points, and not suited for dokku's use case. There is no need to run all those services on all deployed apps.

ghost commented 10 years ago

Thanks for the comments guys. I should also clarify that in addition to the output file being blank, the actual method that is suppose to execute (sending an e-mail to all users at the end of the day) does not occur. Again, the method does in fact execute when the command is run from the command line. This is on a DigitalOcean server.

plietar commented 10 years ago

What dokku version are you running on ? Run dokku version Can you try and redirect stderr to that file as well ? That will probably give some more information.

ghost commented 10 years ago

dokku version is v0.2.1

Here is the output of stderr:

stdin: is not a tty
/bin/bash: dokku: command not found

This seems to be getting somewhere.

Update: I manually specified the dokku executable in the crontab (/root/dokku/dokku) and am no longer seeing the "command not found" error. However, I am still seeing the stdin: is not a tty, which is not dokku related. I will use other resources to correct this.

plietar commented 10 years ago

Why is the dokku script in /root/dokku ? Did you run make install ? That should have copied it to /usr/local/bin. Not sure if that's in cron's PATH thought, which might be the reason it failed initially. Dokku will need in to be in it to use pluginhook, so I'd recommend adding it (the run command might work w/o, but still, would be a good idea.)

For the stdin, try removing the -l option from bash. You might need to close stdin first or it might hang:

bash -c ': | PATH="$PATH:/usr/local/bin" dokku run ...'

Anyway, did the command execute with the full path ?

plietar commented 10 years ago

Also as a general notice, be careful when running dokku as root. The latest code drops the privileges when running under another user. v0.2.1 doesn't. Again this is probably harmless for the run command, but to be sure, I would prefix the dokku command by sudo -u dokku

rawrmaan commented 10 years ago

Thenks plietar--adding sudo -u dokku fixed cron jobs for me.