原因:cron的环境变量和shell脚本的环境变量不一样
解决办法:
方法一:定时任务里面切换到root执行(亲测可用)
*/5 * * * * su - root -c "/opt/test.sh"
方法二:在脚本里面添加环境变量(未测试过)
vi /opt/tes.sh #!/bin/bash source /etc/profile source ~/.bash_profile ...你的代码块
原因:cron的环境变量和shell脚本的环境变量不一样
解决办法:
方法一:定时任务里面切换到root执行(亲测可用)
*/5 * * * * su - root -c "/opt/test.sh"
方法二:在脚本里面添加环境变量(未测试过)
vi /opt/tes.sh #!/bin/bash source /etc/profile source ~/.bash_profile ...你的代码块