gpt4 book ai didi

bash - 为什么我不能在 crontab 中使用大括号?

转载 作者:行者123 更新时间:2023-11-29 09:28:06 25 4
gpt4 key购买 nike

我最近使用 crontab -e 运行一个 cron 作业,我发现了一些奇怪的行为。以下命令不起作用:

 * * * * * cp /home/username/{*txt,*pdf} /home/username/test/

但以下是

 * * * * * cp /home/username/*txt /home/username/test/

而这两个命令都可以在 bash 中使用。

为什么我不能在 cron 中使用大括号?

最佳答案

我想 cron 默认使用 sh shell 来运行您的命令。 sh 不支持大括号通配符。

IIRC,您可以将以下行添加到您的 crontab:

SHELL=/bin/bash

关于bash - 为什么我不能在 crontab 中使用大括号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24488962/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com