Closed stef204 closed 1 month ago
Hi @stef204,
Please tell me have you tried to add the following line to the crontab as a root user?
* * * * * /usr/bin/docker exec --user www-data -i espocrm /bin/bash -c "cd /var/www/html; /usr/local/bin/php -f cron.php" > /dev/null 2>&1
@lazespo of course I have looked into it. But I fail to see HOW to add this to the crontab.
Can you explain how to do this, when using docker
(not docker compose
)?
What I have tried is to fire up a shell with:
docker exec -it espocrm bash
and then using: crontab -e -u WEBSERVER_USER
but first off, crontab
is not recognized as a command.
Trying docker exec -it espocrm bash -c crontab -e -u WEBSERVER_USER
same, not recognized, obviously.)
I understand I need to replace the variable WEBSERVER_USER
but not completely sure what to use here. I tried www
and www-data
but doesn't matter as the command crontab
is either not on the $PATH
or not present.....
Sorry, I am completely new to this.....
Can you explain please?
@stef204,
The command that I suggested needs to be inserted into the crontab directly of the server where you are using Docker, but not into any Docker container itself.
Please log in to your server as root and enter crontab -e
command, then a text editor will open where you can paste this command:
* * * * * /usr/bin/docker exec --user www-data -i espocrm /bin/bash -c "cd /var/www/html; /usr/local/bin/php -f cron.php" > /dev/null 2>&1
@lazespo Thanks for explaining the above. Now we are getting somewhere.
You mean the crontab
of the local host where docker is running. I think I understand now.
I see something about using a systemd
unit instead. Can I just use that instead of cron
?
I would still need to run this command first: nohup php /path/to/espocrm/daemon.php &
? Every time the container is launched?
@stef204,
I’m glad that I was able to explain this question more clearly.
The daemon is more suitable for using EspoCRM directly on the server (on the host). So the best option for you is to insert the previously mentioned line into the server (host) crontab.
OK, so I have successfully enabled the cronjob, and it is working; I can see the emails inside espocrm now. Thanks a lot!
I am going to have to open another ticket for replying to emails which is not working. The test email does get sent though.
Running Version 8.2.4 in docker (not
docker compose
).All is working smoothly.
I set up a test personal email account, and connections test OK, test email gets sent properly, etc.
How do I set up a cron job inside the container so that emails get fetched? I looked at the instructions but cannot seem to apply them to using espocrm inside docker container.
I can fire up a shell using
docker exec -it espocrm bash
anddocker exec -it espocrm bash -c "pgrep cron"
returns nothing.The admin portal gives this message:
Clueless here. Just getting started with docker so bear with me please.
Note 1: If there is a way to retrieve emails manually, without using a cron job, I might go that route, but I do not think it is possible with espocrm.
Note 2: I tried to fire up a shell and once in, I can see the
cron.php
file.If I then go:php -f cron.php
I get this error message:Could not open input file: cron.php
I'd usually think it's a permission problem but I'm logged in asroot@........
andpwd
is/var/www/html
.I think my shell was not inserting the characters of the file name correctly when typing it, for some reason. Using tab completion, the error message above disappeared after running
php -f cron.php
. Can't see anycron
process running but the message tosetup cron job
(above) is now gone.