Infrastructure 2023-03-17

Encountering 'the input device is not a TTY' When Running Docker Command with Cron

Fix the input device is not a TTY error when running docker exec via cron. The cause is the -it flags: cron has no TTY, so remove -t and -i and use plain docker exec.

Read in: ja
Encountering 'the input device is not a TTY' When Running Docker Command with Cron

Overview

When I tried to run a docker command with cron, I encountered the error "the input device is not a TTY".

An example of what I tried to set in cron is as follows:

* * * * * user docker exec -it container-name mysqldump dbname -uuser -ppassword  > backup.sql

Cause

The -t option assigns a TTY, and -i opens standard input, but these are unnecessary for cron execution.

Solution

Removing the -it options resolves the issue.

Tags: Docker
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles