linux - 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
解决方案
function ban_this {
printf %s "$a" |
while IFS= read -r line; do
echo "$line"
done
}
推荐阅读
- mysql - 从排序表的位置为行赋值
- verilog - Verilog 无符号非恢复除法。语法错误:“我放弃”Icarus Verilog
- angular - Sass 层次结构和多个元素
- python - 在 Python 的终端中作为命令传递的字符串 concat
- javascript - Apexcharts 工具提示 - 如何为烛台图添加额外数据?
- google-analytics - 在 Google Analytics 中从特定域中排除 UTM 参数
- google-app-engine - 部署时 App Engine 找不到文件
- c# - 如何更改 Observable Collection 元素中 Class 的属性?
- c++ - 使用 MinGW 在 Windows 上安装 GMP 时出错
- python - 在 spyder 中运行命令的 Mac 快捷方式