我有一个计划每4分钟运行一次的cronjob.Cron正常运行但是它无法执行它应该运行的.sh文件。遵循以下规则:
*/15 * * * * cd /var/www/html/etl_project && ./run_etl_incomplete.sh >> /var/www/html/etl_project/cron_log.txt 2>&1
在cron_log.txt中我收到以下权限被拒绝错误:
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
/bin/sh: 1: ./run_etl_incomplete.sh: Permission denied
答案 0 :(得分:1)
我假设您自己的个人用户正在使用此cron,该cron无权执行该文件。也许该文件是以root用户或其他用户身份创建的,因此凭据未设置为允许用户执行。
首先 - 尝试检查文件上设置的权限
ls -l /var/www/html/etl_project/ | grep run_etl_incomplete.sh
检查输出以查看谁是所有者和组以及设置了哪些权限。
使文件可执行 -
chmod +x /var/www/html/etl_project/run_etl_incomplete.sh
仅当您首先拥有正确的权限(例如,如果您的用户是该组的一部分)才能修改文件时,此功能才有效。 一旦文件可执行,你的cron就会运行。