![Ubuntu cron.daily는 Shell glob을 사용할 때 경로 오류를 반환합니다. 내 경로에 무슨 문제가 있나요?](https://linux55.com/image/129799/Ubuntu%20cron.daily%EB%8A%94%20Shell%20glob%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%A0%20%EB%95%8C%20%EA%B2%BD%EB%A1%9C%20%EC%98%A4%EB%A5%98%EB%A5%BC%20%EB%B0%98%ED%99%98%ED%95%A9%EB%8B%88%EB%8B%A4.%20%EB%82%B4%20%EA%B2%BD%EB%A1%9C%EC%97%90%20%EB%AC%B4%EC%8A%A8%20%EB%AC%B8%EC%A0%9C%EA%B0%80%20%EC%9E%88%EB%82%98%EC%9A%94%3F.png)
Ubuntu 16.04에서 이것은 내 코드입니다 /etc/cron.daily/cron_daily
.
#!/bin/bash
for dir in "/var/www/html/*/"; do
if pushd "$dir"; then
wp plugin update --all --allow-root
wp core update --allow-root
wp language core update --allow-root
wp theme update --all --allow-root
rse
popd
fi
done
어제 이것을 설정했는데 오늘 이메일에 다음 오류가 나타났습니다.
/etc/cron.daily/cron_daily:
/etc/cron.daily/cron_daily: 3행: 푸시: /var/www/html/*/: 해당 파일 또는 디렉터리 없음
왜 이런 일이 발생합니까? 따옴표가 쉘 와일드카드를 방지한다고 가정합니다. 그렇다면 이를 대체하기 위해 무엇을 사용해야 합니까?
답변1
큰따옴표 내에서는 경로 확장이 작동하지 않습니다.
간단한 테스트:
$ ls -ld /lib*
drwxr-xr-x 23 root root 4096 Jul 14 2017 /lib
drwxr-xr-x 2 root root 4096 Jun 21 2017 /lib64
$ ls -ld "/lib*"
ls: cannot access '/lib*': No such file or directory
답변2
*를 사용한 경로 확장은 큰따옴표 안에서 작동하지 않습니다.
다음을 시도해 볼 수 있습니다.
#!/bin/bash
for dir in /var/www/html/*/; do
if pushd "$dir"; then
wp plugin update --all --allow-root
wp core update --allow-root
wp language core update --allow-root
wp theme update --all --allow-root
rse
popd
fi
done