比如在脚本test.sh中使用ifconfig命令获取网卡信息,
#!/bin/sh
exec 1>test.log 2>&1
echo `ifconfig`
在crontab中加入每分钟执行一次.
查看日志test.log会有报错: ifconfig: 未找到命令
原因分析:在crontab中执行的命令必须使用全路径。
查看命令的全路径的方法:
[root@root root]# which ifconfig
/usr/sbin/ifconfig
比如在脚本test.sh中使用ifconfig命令获取网卡信息,
#!/bin/sh
exec 1>test.log 2>&1
echo `ifconfig`
在crontab中加入每分钟执行一次.
查看日志test.log会有报错: ifconfig: 未找到命令
原因分析:在crontab中执行的命令必须使用全路径。
查看命令的全路径的方法:
[root@root root]# which ifconfig
/usr/sbin/ifconfig