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.