Error resolution for environment variables in Linux timed tasks

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.