Crontab: It's not easy to love you.

Source: Internet
Author: User
Tragic background

The machine running the active script cannot connect to toastserver,
I can only write a script myself and run it every day.
Of course, it should be placed in crontab.
5 3 * * * sh ~/nosecron.sh

Even more tragic results

The next day, I checked the results and fail was mostly used.

Annoying Analysis

Many of them are due:
catch_pkts.append(pkt.getlayer(IP).build())
AttributeError: ‘NoneType‘ object has no attribute ‘build‘

Then there is a sentence at the beginning of log:
WARNING: Failed to execute tcpdump. Check it is installed and in the PATH
Run tcpdump manually, OK
Manually run nosecron. Sh, OK
Added the echo $ path to nosecron. SH and put it in the crontab to run it again. There are only:
/Usr/sbin:/usr/bin

High-speed Solutions

Add
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Clever Solution

In crontab:
5 3 * * * su - root -c "sh /root/nosecron.sh"

Once and for all

Add the following to the front of crontab:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Unfortunately, I don't know why it doesn't take effect.

Crontab: It's not easy to love you.

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.