How to solve the problem of cron executing docker failure

藏色散人
Release: 2022-01-04 16:19:56
Original
2600 people have browsed it

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'
Copy after login

Correction--> Success

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!