Solution: disable ubuntucrontab execution

Source: Internet
Author: User
This article introduces the solution to disable Ubuntu crontab execution. you can add the following sentence in the second line of the script file. For more information, see Ubuntu.

Add the following sentence to the second line of the script file:


Copy codeThe code is as follows:
PATH =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

The following describes how to solve the problem:

1. the reason for not executing is caused by environment variables.

2. no default environment variable configuration method is found for cron configuration.

Vim/etc/crontab: the environment variables in this file are correct.

3. *****/root/test. sh> ifconfig.txt 2> & 1 & execute test. sh once every minute

The content of test. sh is as follows. the environment variable of the output result is/usr/bin:/bin.

Copy codeThe code is as follows:
#! /Bin/bash
# PATH =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
Ifconfig
Echo $ PATH

 
Output:

Copy codeThe code is as follows:
/Root/test. sh: line 3: ifconfig: command not found
/Usr/bin:/bin

4. view the ifconfig location

Copy codeThe code is as follows:
Ubuntu "> root @ ubuntu :~ # Whereis ifconfig
Ifconfig:/sbin/ifconfig/usr/share/man/man8/ifconfig.8.gz

5. comment out the second line of the test. sh script. the output result is as follows:

Copy codeThe code is as follows:
Eth0 Link encap: Ethernet HWaddr aa: 00: 04: 00: 0a: 04
Inet addr: 192.168.1.60 Bcast: 0.0.0.0 Mask: 255.255.255.0
Inet6 addr: fe80: 20c: 29ff: fef8: 73b6/64 Scope: Link
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 2093659 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 1532815 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 fig: 1000
RX bytes: 519122457 (519.1 MB) TX bytes: 447226592 (447.2 MB)
Lo Link encap: Local Loopback
Inet addr: 127.0.0.1 Mask: 255.0.0.0
Inet6 addr: 1/128 Scope: Host
Up loopback running mtu: 16436 Metric: 1
RX packets: 433596 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 433596 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 23228192 (23.2 MB) TX bytes: 23228192 (23.2 MB)

/Usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

 

6. the test. sh script temporarily changes the PATH value, and takes effect only in the current script.

Related Article

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.