# Apache + crontab centos

**URL:** <https://forums.docker.com/t/apache-crontab-centos/61724>\
**Category:** General\
**Created:** [October 30, 2018, 4:40pm UTC](https://forums.docker.com/t/apache-crontab-centos/61724 "2018-10-30T16:40:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![royalland123](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@royalland123](https://forums.docker.com/u/royalland123)\
**Post date:** [October 30, 2018, 4:40pm UTC](https://forums.docker.com/t/apache-crontab-centos/61724/1 "2018-10-30T16:40:39Z")

</div>

have a problem i can not make crontab work. it is installed correctly but it does not turn.

here is my dockerfile:

```auto
FROM s2144tds.mc2.xxxxx.fr:5000/bases-ope/php:5.6

ARG TAG_GIT="not define"

LABEL maintainer_name="xx.xx-extern@xxx.com"
LABEL maintener_mail="<xx.xx-extern@xxx.com>"
LABEL description="xx-xx-bdl"
ENV VERSION=${TAG_GIT}
LABEL TAG_GIT=${TAG_GIT}

COPY ./src /sources/.
RUN yum -y install cronie
RUN crond -s
EXPOSE 8082
USER apachephp
ENTRYPOINT ["/usr/local/apache2/bin/httpd"]
CMD ["-D", "FOREGROUND"]

```

I run the page crontab.php

```auto
$txt = "*/1 * * * * ls >> /tmp/log.txt \n";
exec('crontab -r');

file_put_contents('/tmp/crontab.txt', $txt);
exec('crontab /tmp/crontab.txt');

exec("crontab -l ", $output, $result);

var_dump( $output);

```

it works well but the crontab does not launch

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![terpz](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/terpz/32/36125_2.png) [@terpz](https://forums.docker.com/u/terpz)\
**Post date:** [October 31, 2018, 1:01pm UTC](https://forums.docker.com/t/apache-crontab-centos/61724/2 "2018-10-31T13:01:47Z")

</div>

Hi

Its because you have the cron deamon, in the dockerfile, this will only run, on build of the image, and not as a process in the container.

If you want to have 2 services to run at the same time, apache and cron, take a look at [this](https://www.curtisz.com/running-crons-in-docker-with-supervisord-2/)

---

<div class="post-metadata">

**Author:** ![royalland123](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@royalland123](https://forums.docker.com/u/royalland123)\
**Post date:** [November 2, 2018, 2:44pm UTC](https://forums.docker.com/t/apache-crontab-centos/61724/3 "2018-11-02T14:44:35Z")

</div>

Continuing the discussion from [Apache + crontab centos](https://forums.docker.com/t/apache-crontab-centos/61724/2):

Finaly

Solution just add this :

```
COPY ./src /sources/.
RUN yum -y install crontabs
RUN sed -i -e '/pam_loginuid.so/s/^/#/' /etc/pam.d/crond
RUN chmod 0644 /etc/crontab
CMD crond && tail -f /dev/null

EXPOSE 8082
USER apachephp
ENTRYPOINT ["/usr/local/apache2/bin/httpd"]
CMD ["-D", "FOREGROUND"]
```
