> ## Content Index
> Fetch the complete content index at: https://bongholee.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Crontab Log에 "docker: command not found"가 보일 때
- URL: https://bongholee.com/crontab-loge-docker-command-not-found-ga-boil-ddae/
- Published: 2022-02-03T15:00:00.000Z
- Updated: 2022-04-23T06:57:45.000Z
- Author: Bongho Lee
- Tags: docker, #Import 2026-11-22 06:32

며칠 전부터 Crontab으로 진행하고 있던 Backup이 제대로 진행되지 않아서 Log를 훑어보니 다음과 같이 "command not found" Error가 발생하는 것을 확인할 수 있었다.

```shell
Making backup folder for 2022-02-04_01-00
Saving Database Backup in Docker 2022-02-04_01-00
/xx/xx/backup.sh: line 9: docker: command not found
```

관련되어서 Stackoverflow를 뒤져보니 다음과 같은 조언이 있었다.([참고](https://stackoverflow.com/questions/64118478/command-not-found-in-sh-script-running-from-crontab?noredirect=1&lq=1&ref=bongholee.com)) 주요 내용은 스킵하고 솔루션은 다음과 같다. 물어본 분은 Python Script를 cron으로 실행하고 싶었나 보다.

관련되어서 Stackoverflow를 뒤져보니 다음과 같은 조언이 있었다.([참고](https://stackoverflow.com/questions/64118478/command-not-found-in-sh-script-running-from-crontab?noredirect=1&lq=1&ref=bongholee.com)) 주요 내용은 스킵하고 솔루션은 다음과 같다. 물어본 분은 Python Script를 cron으로 실행하고 싶었나 보다.

> **'which python3' - a possible result is /usr/bin/python3** 
> **'Add the result of #1 to the crontab command**  

> **A general advice:** 
> **Use full path to every resource your sh script is using**

쉽게 정리하면 Crontab의 기본 Path 변수로는 Docker의 위치를 파악하고 있지 못해서 발생한 문제이기 때문에 1) Full Path를 적어주던지, 2) Path 환경변수에 추가해줘서 Docker를 인식하도록 바꿔주면 된다.

Export를 써서 기존 $PATH에 docker의 위치로 포함시켜주었다. 이제 남은 것은 에러가 나지 않길 바랄 뿐이다.

---

(2022.02.06 업데이트)

이렇게 해도 에러가 나는 부분이 있어서, $Full\_Path/docker 형태형 Full Path를 모두 Crontab에 기재해주었고, 현재는 에러가 나지 않는다.