# Cron in docker container (Cannot make/remove an entry for the specified session)

**URL:** https://meta.discourse.org/t/cron-in-docker-container-cannot-make-remove-an-entry-for-the-specified-session/148969
**Category:** Support
**Created:** [April 23, 2020, 9:55am UTC](https://meta.discourse.org/t/cron-in-docker-container-cannot-make-remove-an-entry-for-the-specified-session/148969 "2020-04-23T09:55:44Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![maltfield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maltfield/32/160669_2.png) [@maltfield](https://meta.discourse.org/u/maltfield)
#### Post date: [April 23, 2020, 9:59am UTC](https://meta.discourse.org/t/cron-in-docker-container-cannot-make-remove-an-entry-for-the-specified-session/148969/2 "2020-04-23T09:59:09Z")

</div>

This is the result of a bug in docker and Debian. It’s since been fixed, but apparently not for Discourse’s docker image (yet?).

- [https://stackoverflow.com/questions/43323754/cannot-make-remove-an-entry-for-the-specified-session-cron](https://stackoverflow.com/questions/43323754/cannot-make-remove-an-entry-for-the-specified-session-cron)

Per the above link, I used the following template file to both [a] create the `/etc/cron.d/` file and [b] fix the bug in the `cron` pam module:

```plaintext
[root@osestaging1 discourse]# cat /var/discourse/templates/unattended-upgrades.template.yml run:
  - file:
     path: /etc/cron.d/unattended-upgrades
     contents: |+
        ################################################################################
        # File: /etc/cron.d/unattended-upgrades
        # Version: 0.1
        # Purpose: run unattended-upgrades in lieu of systemd. For more info see
        # * https://wiki.opensourceecology.org/wiki/Discourse
        # * https://meta.discourse.org/t/does-discourse-container-use-unattended-upgrades/136296/3
        # Author: Michael Altfield <michael@opensourceecology.org>
        # Created: 2020-03-23
        # Updated: 2020-03-23
        ################################################################################
        20 04 * * * root /usr/bin/nice /usr/bin/unattended-upgrades --debug
        

  - exec: /bin/echo -e "\n" >> /etc/cron.d/unattended-upgrades
  # fix the Docker cron bug https://stackoverflow.com/questions/43323754/cannot-make-remove-an-entry-for-the-specified-session-cron
  - exec: /bin/sed --in-place=.`date "+%Y%m%d_%H%M%S"` 's%^\([^#]*\)\(session\s\+required\s\+pam_loginuid\.so\)$%\1#\2%' /etc/pam.d/cron
[root@osestaging1 discourse]# 

```

Unfortunately, I’m not 100% of all the consequences of making this change to the `cron` pam.d module. But it does _seem_ to me to be the recognized fix upstream :\

See also: [Does Discourse container use unattended-upgrades? - #9 by maltfield](https://meta.discourse.org/t/does-discourse-container-use-unattended-upgrades/136296/9)

---

_[View the full topic](https://meta.discourse.org/t/cron-in-docker-container-cannot-make-remove-an-entry-for-the-specified-session/148969)._
