1.原因:
执行环境的不同
2.解决办法:
添加环境变量
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
3. 完整示例:
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
echo "------------ begin monitor ----------" >/root/log.txt
whoami >>/root/log.txt
echo '清空redis' >>/root/log.txt
redis-cli flushall >>/root/log.txt
echo '项目重新启动' >>/root/log.txt