Error executing script in crontab

Recently, I have often encountered the inability to execute crontab. The following reasons are initially summarized:
First, the reason for the script: In most cases, it is the problem of our script. This kind of problem causes the probability that the crontab cannot be executed to account for 70%. %above. Because the program executes to a certain step, the crontab terminates execution, such as a database access error, etc.
Second, the execution environment problem. When we encounter the first case, we can generally kill the problem in the cradle by manually executing the program. Generally, experts should not make the first mistake. The problem is that when we manually execute successfully but crontab cannot be executed, the author encounters a problem with the execution environment, such as the setting of related paths. Solution: Execute source /home/user/.bash_profile at the top of the code, or source /etc/profile. Another situation is that the log does not appear in the corresponding location, which is generally the use of a relative directory instead of an absolute directory.
Third, the system time is incorrect. This kind of problem is best understood, and it is also a relatively common and hidden problem. The solution: date -s ********
Fourth, is whether our script has executable permissions. It must be ensured that the user executing the script has permission to execute the modified file.
Fifth, the crontab daemon died. This situation is rare, but it cannot be ruled out. It can be used when we really can't find other reasons. Solution: Restart the process.
In addition, I will introduce you a method on how to check the most modified time of crontab:
enter the directory /var/spool/cron/, there will be N files with the name of the file name, as long as the user who has created crontab will have the file name here The user name is the file with the file name, and the last modification time of the file is the last modification time of the user's crontab.

Note: After crontab -e is edited, the task will take effect immediately

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326592299&siteId=291194637