This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
线索就在错误消息中:
注意它说的是“sh”。 Bourne shell 不支持 Bash 特有的某些功能。如果您使用 Bash 功能,那么您需要告诉 Bash 运行该脚本。
将文件的第一行设置为:
或在 crontab 条目中执行以下操作:
如果没有看到 crontab 条目和脚本,则很难更具体。
The clue is in the error message:
Notice that it says "sh". The Bourne shell doesn't support some features that are specific to Bash. If you're using Bash features, then you need to tell Bash to run the script.
Make the first line of your file:
or in your crontab entry do this:
Without seeing your crontab entry and your script it's hard to be any more specific.
也许您应该在
backups.sh
中做的第一件事是插入cd /home/user1
。 crond 可能会从与您想象的不同的目录执行您的脚本,并且无论它如何执行,强制它使用相同的目录可能是一个很好的开始。另一个可能有用的调试步骤是添加
id > /tmp/id.$$
或类似的内容,这样您就可以准确地看到正在使用哪些用户帐户和组来运行脚本。Perhaps the first thing you should do in your
backups.sh
is insert acd /home/user1
.crond
may execute your script from a different directory than you think it does, and forcing it to use the same directory regardless of how it is executed could be a good first start.Another potentially useful debugging step is to add
id > /tmp/id.$$
or something like that, so you can see exactly which user account and groups are being used to run your script.在crontab中,只需将2>$1更改为2>&1即可。我自己刚刚做了一件。谢谢丹尼斯·威廉姆森。
In crontab, just change 2>$1 to 2>&1. I've just done one myself. Thank you Dennis Williamson.