Crontab Debug error information in Linux

Source: Internet
Author: User

Look at this crontab down here.

* * * * * * */usr/bin/python/home/zhangdapeng/del.py >/dev/null 2>&1

Generally safer, without disturbing the case is like this

But debugging is inconvenient, the error, do not know why the error, can't find the reason, change

* * * * * * */usr/bin/python/home/zhangdapeng/del.py >/path/result.log 2>&1

That way, you can know the reason in Result.log.

Actually, I think one of the most common problems with Crontab is that the environment variables are wrong. You will often see someone in the forum asking, "Why did my Crontab create a no execution?" When you're ready to create a Cron JOB, a lot of people like to run it at the command line, because the environment variable is automatically brought in with the Shell, and in Crontab, the job cannot be executed because the correct environment variable is not found. This little problem is like smallpox, after a lesson is remembered.

A skill that must be used
After each JOB completes, the system automatically sends the output to the current system user. Over and over, very much, even the whole system will explode. So it is necessary to redirect each JOB command back: >/dev/null 2>&1. The premise is that the normal output of the commands in the JOB needs to be processed, such as appending to a particular log file.

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.