Linux crontab log description

Source: Internet
Author: User

Crontab is the most common scheduled Task Service in Linux. This article will share with you some experiences on storing linux crontab logs. I hope this article will teach you more.

By default, logs executed in crontab are written in/var/log, for example:

# Ls/var/log/cron *
/Var/log/cron/var/log/cron.1/var/log/cron.2/var/log/cron.3/var/log/cron.4

If there is a log problem, you can refer to the following practices:

Add logs for crontab

Crontab logs are relatively simple. When crond fails to execute the task, it will send an email to the user. It happened that a task was not executed normally on one of our servers, and crond failed to send emails. By reading the mail log, we can see that the disk space is insufficient.

In addition, my colleagues help me add my own logs for the tasks in crontab, which makes it easy to see the cause after an error occurs.

0 6 * ** $ HOME/for_crontab/createTomorrowTables> $ HOME/for_crontab/mylog. log 2> & 1

Output both error output and standard output to mylog. log.
 
Note: Do not write

0 6 * ** $ HOME/for_crontab/createTomorrowTables 2> & 1> $ HOME/for_crontab/mylog. log

Otherwise, it will be output to the standard output.

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.