In UNIX and UNIX like operating systems, the crontab command is often used to set the instructions to be executed periodically, which can also be understood as setting the timing task.
Sometimes the timing task in crontab is not executed successfully. What’s the reason?At this time, we need to go to the log to analyze it. How to view the log records of crontab?
Look at/var/log/ cron.log This file can be viewed with tail – F/var/log/cron
In the/var/spool/cron/tmp file, there are croutxxx001864 TMP files. You can see the tasks being executed from these files.
3. Mail task
In the/var/spool/mail/root file, there is a record of crontab execution log. Use tail – F/var/spool/mail/root to view the latest crontab execution.
A friend asked about whether the crontab of Linux has been executed or not. He has also written some shell scripts for basic backup. Combined with his own actual production environment, he briefly describes how to analyze whether the crontab is executed correctly through the cron execution log.
For example, Oracle users under the server have the following scheduled tasks
[[email protected] ~]$ crontab -l 00 1 * * 0 /home/oracle/backup/hollyipcc.sh 00 1 1 * * /home/oracle/backup/hollyreport_hollycrm.sh
The planned tasks of the system will be in/var/log first
[[email protected] ~]# cd /var/log/ [[email protected] log]# less cron Sep 22 04:22:01 localhost crond: (root) CMD (run-parts /etc/cron.weekly) Sep 22 04:22:01 localhost anacron: Updated timestamp for job `cron.weekly' to 2013-09-22 Sep 22 05:01:01 localhost crond: (root) CMD (run-parts /etc/cron.hourly) Sep 22 06:01:01 localhost crond: (root) CMD (run-parts /etc/cron.hourly) Sep 22 07:01:01 localhost crond: (root) CMD (run-parts /etc/cron.hourly) Sep 22 08:01:01 localhost crond: (root) CMD (run-parts /etc/cron.hourly)
The above/var/log/cron will only record whether some planned scripts have been executed, but Linux will send email to the user every time to check whether the specific execution is correct and some information in the process of script execution.
As mentioned above, Linux will send an email to/var/spool/mail
[[email protected] log]# cd /var/spool/mail/ [[email protected] mail]# less oracle Date: Sun, 25 Aug 2013 01:00:01 +0800 Message-Id: <[email protected]> From: [email protected] (Cron Daemon) To: [email protected] Subject: Cron /home/oracle/backup/hollyipcc.sh Content-Type: text/plain; charset=UTF-8 Auto-Submitted: auto-generated X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: backup hollyipcc Export: Release 10.2.0.4.0 - Production on Sunday, 25 August, 2013 1:00:02 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01": system/******** dumpfile=hollyipcc_20130825.dmp logfile=hollyipcc_20130825.log directory =back schemas=hollyipcc parfile=/home/oracle/backup/parfile.par Estimate in progress using BLOCKS method... Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 5.932 GB Processing object type SCHEMA_EXPORT/TABLE/TABLE Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS . . exported "HOLLYIPCC"."BASE_CONTACTSTATE_BAK":"P201203" 1.389 GB 15716014 rows
At this point, we can well judge whether the crontab script is executed, whether it is correct in the process of execution, and some error information. I hope this can help some friends understand the principle of crontab and diagnose the problems of crontab.
- Delete the specified crontab timer task under Linux
- Mac reports an error zsh: fork failed: resource temporarily unavailable (reasons and solutions)
- How can Oracle query tables of other users without adding a table user name
- Using apt mirror to build Debian local warehouse
- Backup and recovery – rman4
- Analysis of [error code , ora-00942 in synchronization of DDL statements in ogg
- It can’t connect to local MySQL server through socket ‘/ tmp/ mysql.sock ‘(2) “;
- [Linux] e297: write error in swap file solution
- How to make the import complete smoothly!
- What is the schema in the database?
- About ora-00257: archiver error. Connect internal only, until free
- Export and import method of MySQL under Linux
- Solution of Oracle error 6550
- TNS-12545: Connect failed because target host or object does not exist
- Split keyword in ABAP when the separator is at the beginning and end of the string
- ERROR 1406 (22001): Data Too Long, field len 30, data len 48
- mysql ERROR 1050 (42S01): Table already exists
- com.microsoft.sqlserver . jdbc.SQLServerException : invalid object name ‘XX’
- Solution to MySQL Error 1130 problem
- MYSQL login error: mysqladmin: connect to server at’localhost’ failed