Linuxcron scheduled task log tracking

Source: Internet
Author: User

Linuxcron scheduled task log tracking

Scenario: You need to enable a scheduled task in the cron of the system and run a shell script, which roughly means switching

The abc user executes a php file (for example,/data/soft/auto. php), so now the problem is that

The content is as follows:

 

#! /Bin/bashsudo-u abc/data/soft/auto. phpecho '>>> auto success !!! '

You will find that the system's/var/log/cron log shows auto success, but this program still

No execution. How do you know it is not executed? Because the program has logs, the logs are not flushed.

So how can we find out why the program is not executed? The idea is that every time you execute cron, a record file will be generated.

Find the File Location Based on the system version:

View/var/spool/clientqueue/for operating system version 4/5/

Operating system version 6 view/var/spool/postfix/maildrop/

The system's postfix is stopped. If it is not stopped, you can directly run the mail command to check whether it is stopped.

After entering the corresponding directory, you can use the ls-lt | head command to capture the last 10 cron log files that are executed. You can determine the time based on the time.

Which file must contain an error. Modify the script or system attributes based on the error.

Two situations I have encountered:

1. sudo system default warning requires tty. Solution: comment out the ults requiretty in the/etc/sudoers file.

2. Caused by the variable path, load the variables or definitions you need.

I haven't written it for a long time. This problem is worth recording. I believe many people still don't know this troubleshooting method, which is just learned from others.

 

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.