过程

昨天在Linux执行Shell脚本的时候,把脚本执行结果写入到指定路径下的日志文件,然后报错

sh /home/mysql/sql/test/test.sh param,param2,param3 >> $logsPath/testfile.log 2>&1
-bash: /testfile.log: Permission denied

原因

因为这个脚本是从其他脚本中摘出来的一条语句,写入日志使用了变量logsPath,而单独摘出来,该变量没有定义,所以报错

解决方案

把变量换成要写入日志的相对或者绝对路径就好了。

GitHub 加速计划 / li / linux-dash
10
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:17 天前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐