# Cant find cron log files

**URL:** <https://forums.balena.io/t/cant-find-cron-log-files/3721>\
**Category:** Product support\
**Created:** [August 12, 2018, 10:48pm UTC](https://forums.balena.io/t/cant-find-cron-log-files/3721 "2018-08-12T22:48:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreed47](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dreed47/32/1099_2.png) [@dreed47](https://forums.balena.io/u/dreed47)\
**Post date:** [August 12, 2018, 10:48pm UTC](https://forums.balena.io/t/cant-find-cron-log-files/3721/1 "2018-08-12T22:48:16Z")

</div>

I have a container up and running on my raspberry PI 3. I have a couple of cron jobs setup but I cant find where the log file entries are going. Any suggestion where I can find them?

---

<div class="post-metadata">

**Author:** ![stooshie45](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@stooshie45](https://forums.balena.io/u/stooshie45)\
**Post date:** [August 13, 2018, 7:32am UTC](https://forums.balena.io/t/cant-find-cron-log-files/3721/4 "2018-08-13T07:32:46Z")

</div>

What file have you told the job to log to?

---

<div class="post-metadata">

**Author:** ![dreed47](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dreed47/32/1099_2.png) [@dreed47](https://forums.balena.io/u/dreed47)\
**Post date:** [August 13, 2018, 2:46pm UTC](https://forums.balena.io/t/cant-find-cron-log-files/3721/5 "2018-08-13T14:46:35Z")

</div>

Sorry, I’m new to [resin.io](http://resin.io) and new to Docker.

I didn’t specify where to log cron runs. My device is a raspberry Pi 3 running ResinOS. My Dockerfile.template is pasted below. I’ve looked in the standard places for raspberry PI and Linux systems but I cant seem to find them.

```auto
FROM resin/%%RESIN_MACHINE_NAME%%-node:6

# Install other apt deps
RUN apt-get update && apt-get install -y \
  xserver-xorg-core \
  xserver-xorg-input-all \
  xserver-xorg-video-fbdev \
  xorg \
  fluxbox \
  python-imaging-tk \
  unzip \
  cron && rm -rf /var/lib/apt/lists/*

# Set Xorg and FLUXBOX preferences
RUN mkdir ~/.fluxbox
RUN echo "xset s off" > ~/.fluxbox/startup && echo "xserver-command=X -s 0 dpms" >> ~/.fluxbox/startup

RUN echo "#!/bin/bash" > /etc/X11/xinit/xserverrc \
   && echo "" >> /etc/X11/xinit/xserverrc \
   && echo 'exec /usr/bin/X -s 0 dpms -nocursor -nolisten tcp "$@"' >> /etc/X11/xinit/xserverrc

# Defines our working directory in container
WORKDIR /usr/src/app

# Copies the package.json first for better cache on later pushes
COPY package.json package.json

# This install npm dependencies on the resin.io build server,
# making sure to clean up the artifacts it creates in order to reduce the image size.
RUN JOBS=MAX npm install --production --unsafe-perm && npm cache clean && rm -rf /tmp/*

# This will copy all files in our root to the working directory in the container
COPY . ./

# Install cronjobs to turn display on and off
RUN crontab jobs.txt

# Enable systemd init system in container
ENV INITSYSTEM on

# Start app
CMD ["bash", "/usr/src/app/start.sh"]

```

---

<div class="post-metadata">

**Author:** ![stooshie45](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@stooshie45](https://forums.balena.io/u/stooshie45)\
**Post date:** [August 14, 2018, 9:01am UTC](https://forums.balena.io/t/cant-find-cron-log-files/3721/6 "2018-08-14T09:01:35Z")

</div>

Okay, are you looking in the Host OS or inside the container? I presume this is a single container setup?

---

<div class="post-metadata">

**Author:** ![dreed47](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dreed47/32/1099_2.png) [@dreed47](https://forums.balena.io/u/dreed47)\
**Post date:** [August 14, 2018, 1:30pm UTC](https://forums.balena.io/t/cant-find-cron-log-files/3721/7 "2018-08-14T13:30:30Z")

</div>

I looked in both places. The cron is running inside the container. Yes its a single container setup.

---

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [August 15, 2018, 2:21pm UTC](https://forums.balena.io/t/cant-find-cron-log-files/3721/8 "2018-08-15T14:21:17Z")

</div>

Hi @dreed47, I’ve checked it out, and by default, with the `INITSYSTEM=on`, the logs are in the normal systemd logs, not sent to a specific file. You can see them with `journalctl -u cron` (the `cron` service’s logs).

I see the jobs being triggered there just fine, such as:

```bash
...
Aug 15 14:11:01 253c3ec CRON[183]: pam_env(cron:session): Unable to open env file: /etc/default/locale: No such file or directory
Aug 15 14:11:01 253c3ec CRON[183]: pam_unix(cron:session): session opened for user root by (uid=0)
Aug 15 14:11:01 253c3ec CRON[184]: (root) CMD (echo "crontab job at $(date)")
Aug 15 14:11:01 253c3ec CRON[183]: (CRON) info (No MTA installed, discarding output)
Aug 15 14:11:01 253c3ec CRON[183]: pam_unix(cron:session): session closed for user root
...

```

If you want your jobs to have any output, you might have to either install `postfix` (hence the `No MTA installed, discarding output` message), or you can set your job up in a way that it saves to a file. See more info e.g. in this StackOverflow:

> <https://askubuntu.com/questions/222512/cron-info-no-mta-installed-discarding-output-error-in-the-syslog>

Does this help?

---

<div class="post-metadata">

**Author:** ![dreed47](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dreed47/32/1099_2.png) [@dreed47](https://forums.balena.io/u/dreed47)\
**Post date:** [August 15, 2018, 2:31pm UTC](https://forums.balena.io/t/cant-find-cron-log-files/3721/9 "2018-08-15T14:31:19Z")

</div>

> [@imrehg](#):
>
> journalctl -u cron

Yes, that helped very much! Thanks!

---

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [August 15, 2018, 2:35pm UTC](https://forums.balena.io/t/cant-find-cron-log-files/3721/10 "2018-08-15T14:35:46Z")

</div>

Great to hear!

Yeah, if using systemd, would recommend checking out `journalctl` and `systemctl`, for some handy tricks.

For example in this case, if you run with the `-f` flag to follow the logs of the specific unit, e.g. `journalctl -f -u cron`, then it will keep the flow open, and you’ll see whenever new logs come in. #tips

Also, besides crontab, if you use systemd already, could recommend checking out systemd timers, they are quite handy and versatile too, see for example [https://wiki.archlinux.org/index.php/Systemd/Timers](https://wiki.archlinux.org/index.php/Systemd/Timers) But if you are comfortable with cron, that should be fine too. 🙂
