linux crontab调用脚本中的ifconfig命令返回为空
2023-01-10 10:42:23
by 山阴客

打印???
山阴客(http://www.shanyinke.com)
技术文章(http://www.shanyinke.comhref=category.php?cid=1)
LINUX文章(http://www.shanyinke.comhref=category.php?cid=3)

linux crontab调用脚本中的ifconfig命令返回为空

 

crontab 调用脚本中的ip=`ifconfig eth0 | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`

返回值为空,手动执行执行能够正确地返回ip地址,crontab调用不可以

把脚本中ifconfig 改成全路径/sbin/ifconfig 问题解决

ip=`/sbin/ifconfig eth0 | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
————————————————
版权声明:本文为CSDN博主「wangwei」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weiwangsisoftstone/article/details/38901087



Copyright © 2002 myarticle.com.cn
All rights reserved.

备案号:浙ICP备17002154号-3 Powered by: MyArticle Version 1.0dev
Processed Time: 0.0014 s Querys: 4 [ Gzip Level 0 ]