The script should be executable: chmod u+x /root/Backup/backup.sh
Alternatively you could change your crontab entry to the following: 36 * * * * /bin/sh /root/Backup/backup.sh
Info: Either you invoke the script directly from /bin/sh or you need to give enough information to the shell (cron's environment) to execute the script with the correct interpreter. That's handled by item 1. Also, since you're attempting to execute the script directly it must be executable.
Try piping stdout and stderr into a file. eg. /..../backup.sh >/tmp/backup-output 2>&1 and checking that. Also check that there is no environment issues between cron running it and you running it on the command line. Put env at the start of the file.
Also are you sure that Backup should start with a capital letter?
发布评论
评论(3)
您缺少两件事:
或者,您可以将 crontab 条目更改为以下内容:
36 * * * * /bin/sh /root/Backup/backup.sh
信息:
要么直接从 /bin/sh 调用脚本,要么需要向 shell(cron 的环境)提供足够的信息以使用正确的解释器执行脚本。这是由第 1 项处理的。此外,由于您尝试直接执行脚本,因此它必须是可执行的。
two things you're missing:
Alternatively you could change your crontab entry to the following:
36 * * * * /bin/sh /root/Backup/backup.sh
Info:
Either you invoke the script directly from /bin/sh or you need to give enough information to the shell (cron's environment) to execute the script with the correct interpreter. That's handled by item 1. Also, since you're attempting to execute the script directly it must be executable.
尝试将 stdout 和 stderr 通过管道传输到文件中。例如。 /..../backup.sh >/tmp/backup-output 2>&1 并检查。还要检查 cron 运行它和在命令行上运行它之间不存在环境问题。将 env 放在文件的开头。
另外您确定备份应该以大写字母开头吗?
Try piping stdout and stderr into a file. eg. /..../backup.sh >/tmp/backup-output 2>&1 and checking that. Also check that there is no environment issues between cron running it and you running it on the command line. Put env at the start of the file.
Also are you sure that Backup should start with a capital letter?
谢谢大家
问题解决了
我在 shell 脚本中使用绝对路径而不是相对路径。
Thank you all of you
The problem is solved
I use absolute path instead of relative path inside the shell script.