Home >Operation and Maintenance >Docker >How to solve the problem of cron executing docker failure

How to solve the problem of cron executing docker failure

藏色散人
藏色散人Original
2022-01-04 16:19:562626browse

Cron fails to execute docker because exec adds the -it parameter. The solution is to correct "docker exec php-7.2_1 /bin/bash -c 'cd /usr/local/nginx/html/MyProject. ..” That’s it.

How to solve the problem of cron executing docker failure

The operating environment of this article: ubuntu16.04 system, Docker 20.10.11, Dell G3 computer.

How to solve the problem of cron failing to execute docker?

crontab failed to execute docker exec command:

Original script--> failed

#!/bin/bash
docker exec -it php-7.2_1 /bin/bash -c 'cd /usr/local/nginx/html/MyProject && sh GatherData.sh'

Correction--> Success

#!/bin/bash
docker exec php-7.2_1 /bin/bash -c 'cd /usr/local/nginx/html/MyProject && sh GatherData.sh'

Cause of failure

Adding the -it parameter to exec opens a terminal, and the scheduled task cannot enter any terminal.

Recommended learning: "docker video tutorial"

The above is the detailed content of How to solve the problem of cron executing docker failure. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn