高级搜索 返回首页  
名人名言
哲理小故事
技术文章
    - LINUX文章
山阴客技术文章LINUX文章linux crontab调用脚本中的ifconfig命令返回为空
linux crontab调用脚本中的ifconfig命令返回为空
2023-01-10 10:42:23
by 山阴客  
Rating: not rated yet
1 2 3 4 5 6 7 8 9 10

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.0025 s Querys: 5 [ Gzip Level 0 ]