Differences between environment variables and shell environment variables in timed tasks shell environment variable path query with echo $PATH command
Echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin Shell Linux environment variables
The environment variable in the timed task path query is to write the Echo $PATH command to the script, and then write the result of the execution to the text query result.
The default internal environment variable for the scheduled task is
It can be seen that the internal environment variable of the timed task path is not complete, only/usr/bin:/bin.
As an example of a ifconfig command, the command to query the command path is which.
which ifconfig/sbin/ifconfig
When you see the results, you know that there is no path to this command in the environment variable path in the timed task.
So when the script joins the Ifconfig command, it will get an error.
[Email protected] scripts]# tailf/server/scripts/log/ip.log/server/scripts/ip. SH 1 ifconfig: Command not found commands not found
How to solve this kind of problem? Query the path with which, and add a path to the command query that is not in the/usr/bin:/bin path.
[[email protected] scripts]# vim IP. SH #!/bin/sh/sbin/ifconfig
? If there are many script commands, you need to re-modify the environment variable path within the timed task.
[[email protected] scripts]# vim IP. SH #!/bin/shexportpath=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/ root/binifconfig
Error resolution for environment variables in Linux timed tasks