首页 > 解决方案 > bash 脚本不作为 cron 执行,而是手动执行

问题描述

手动执行时,脚本本身运行良好。它使 cron 作业失败

function ban_this {
while IFS= read -r line
do
printf $line >> /tmp/test.file
done < <(printf '%s\n' "$a") 
}

a=$(journalctl | grep "client @")
ban_this

标签: linuxbashpathcron

解决方案


function ban_this {
printf %s "$a" |
while IFS= read -r line; do
echo "$line"
done
}

推荐阅读