Crontab command backup log, crontab command logCrontab command to back up logs
Question
James is a server administrator who needs to back up Forum data every day (Here we use logs to replace), back up the logs of the day and delete the previous logs. The file name after the backup is in the format of year-month-day. Alternatives.
/var/log/cron File Save Cron task execution recordCD/var/log/-L cron*Will find a cron log change every day.UseTail-f CronAbility to view logs for today's cron:UseCat/etc/crontabCan seeMailto=root means that when a crontab command or task is executed, a record message is generated to the root userView Root's Mail[[Email
The system of the company's server is CentOS6.4. you often need to use the Crontab command to execute a series of application scripts and encounter various problems, some problems encountered during the use of the Crontab command are summarized as follows for future use. Format Description: For the crontab command format, use a picture of a super-good person on t
The original site is as follows:
Http://blog.itechol.com/space-33-do-blog-id-4945.html
customizing crontab log file Locations
Crontab is the most common scheduled task service under Linux. This article to share with you about Linux crontab log storage experience, I hope thi
I. File locationLocation in general under the/var/spool/cron/, if you are the root user, then there is a root file, recommended daily backup, to avoid accidental deletion resulting in crontab file loss;Two. log file locationBy default, the logs executed in Crontab are written under/var/log, such as:#ls/var/
I. File locationLocation in general under the/var/spool/cron/, if you are the root user, then there is a root file, recommended daily backup, to avoid accidental deletion resulting in crontab file loss;Two. log file locationBy default, the logs executed in Crontab are written under/var/log, such as:#ls/var/
I. File location
Position in general under/var/spool/cron/, if you are root, then there is a root file, recommended daily backup, to avoid accidental deletion caused crontab file loss;
Two. log file location
By default, the log executed in Crontab is written under/var/log
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
To use the Crontab Timer tool, you must start the Cron service:Service Cron StartCrontab syntax for future emergencies. First on the Zhang Chao to force the diagram:Crontab Each participant Description:-E: Run text editor to edit crontab, the default text editor is VI-R: Delete the crontab now-L: List the current crontab
The Crontab log feature under Ubuntu is not automatically turned on. The steps to turn on the log feature are:① modifying Rsyslogsudo vim/etc/rsyslog.d/-default. confFound it:#cron. * /var/log/cron.logGet rid of the front #② Restart Rsyslogsudo service Rsyslog restart③ can now view the logTai
In Linux under the crontab to start a timed script, put in the crontab of dead and dead did not respond, this is the possible reason:
1, look at the log, Cat/var/log/cron. If there is an execution record in the log, it may be that the script does not have permission to exec
Execution steps
1) Edit the specified user under Crontab
Crontab-e WEBLOG10
Press Insert to execute edit
After execution, press INSERT:WQ enter to exit
2 new Scheduled task, 11 17 a day to perform the first compression after the delete command, note that a special character needs to escape
* * * tar cvf/weblog10/applog/test-' date +\%y\%m\%d '. Tar/weblog10/test rm-rf/weblog10/test
If a new schedu
Linux on a timed execution of certain scripts is a common scenario when administering a server, such as the timing of checking the existence of the process, scheduled to start or close the process, check the log deletion log regularly.When I opened Google Baidu crontab a large number of lengthy, detailed explanation of a large pile of various copying to copy, now
To use the crontab timer tool, you must start the cron service:
Service cron start
Crontab syntax for future emergency. First, let's look at the awesome figure:
Crontab parameters:
-E: Execute the text editor to edit crontab. The defined text editor is VI.-R: Delete the current cr
Refer to two better documents.
Http://nic.qhu.edu.cn/data/2005/0907/article_41.htm
Http://lostinmymind.blogchina.com/2239184.html
There are probably two kinds of crontab, one is to modify the global configuration file/etc/crontab, the other is to run the command crontab-e directly.
Global configuration does not have detailed test, it seems to run directly
Crontab can run programs regularly, but sometimes there are problems with the program, and to monitor the program we can view the log of crontab, but unfortunately Linux (Ubuntu) turns off the log of crontab by default, so it's OK to turn on
, and if you do not wish to receive such a letter, please leave a blank space in each lineAfter adding >/dev/null 2>1Example 2:#每天早上6点10分6 * * * Date#每两个小时0 */2 * * * Date#晚上11点到早上8点之间每两个小时, 8 in the morning.0 23-7/2,8 * * * Date#每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点0 4 * mon-wed date#1月份日早上4点0 4 1, * dateExample$crontab-L lists the user's current crontab.
Crontab Command D
can execute the specified system command or shell script at a fixed interval. The time interval can be any combination of minutes, hours, days, months, weeks, and above. This command includes non-permanent and periodic log analysis or data backup.
In the crontab file created by the user, each row represents a task, and each field in each row represents a setting. Its format is divided into six fields. The
, and the following method is consistent * * * * * /home/xxx/crontab/test.sh 1>/home/xxx/crontab/test.log * * * * * /home/xxx/crontab /test.sh >/home/xxx/crontab/test.log 2>1 3. Description 1 represents, standard output, so the above command will output the script output to the
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.