Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Checking and Restarting the Cron Daemon

Expert Oracle Database Tips by Donald BurlesonMarch 22, 2015

Checking and Restarting the Cron Daemon

Scheduling Commands with cron and at

As DBAs, we are often saddled with tasks which must be repeated on a regular schedule and/or must be done off-hours.  Tasks like backups, cleanup routines and monitoring are prime examples of these.

Linux provides two very useful utilities for scheduling these tasks, cronand at.  The cron utility allows a user on the system to set up repeating tasks to be scheduled on a regular basis at a specified time, day of the week or month, and month.  The at utility allows a user to specify a one-time execution of a task sometime in the future.  While both of these tools have their quirks, they are easily mastered and are very useful.

Using cron for Repeating Tasks

Before jumping into how to set up tasks in cron, a little background needs to be covered on it.

The Cron Daemon

The cron daemon is the system process that runs scripted jobs on a pre-determined schedule.  The crontab command is used to tell the cron daemon what jobs the user wants to run and when to run those jobs.  The cron daemon is started through startup scripts in the /etc/rc#.d directories.

Checking and Restarting the Cron Daemon

To check to see if the cron daemon is running, search the running processes with the ps command.  The cron daemon's command will show up in the output as crond.

$ ps -ef | grep crond

root      2560     1  0 07:37 ?        00:00:00 crond
oracle    2953  2714  0 07:53 pts/0    00:00:00 grep crond

The entry in this output for grep crond can be ignored but the other entry for crond can be seen running as root.  This shows that the cron daemon is running.

By default, the cron daemon runs at runlevels 2 through 5 inclusive, but it can occasionally fail and needs to be restarted.  To start or stop the cron daemon, use the crond script in /etc/init.d by providing an argument of start or stop.  You must be root to start or stop the cron daemon.

# /etc/init.d/crond stop
 
Stopping crond:
                                            [  OK  ]
 

# ps -ef | grep crond
 
root      3005  2958  0 08:00 pts/0    00:00:00 grep crond
 
# /etc/init.d/crond start
 
Starting crond:
                                            [  OK  ]


# ps -ef | grep crond
 
root      3013     1  5 08:00 ?        00:00:00 crond
root      3016  2958  0 08:00 pts/0    00:00:00 grep crond

Setting Up and Editing a User's crontab File

A user's list of scheduled jobs is kept in what is referred to as the crontab file.  A crontab file is kept for each user in the /var/spool/cron directory, but unlike most other configuration files, the crontab should never be edited directly.

WARNING: Never edit a user's crontab directly with a text editor.  Always use the crontab command to edit crontab files.

 

 

 

The crontab commandallows you to view, edit or replace a user's crontab file.  This table shows the common options for the crontab command.  Notice that only the root user can change other user's crontabs.

Option Purpose
-e Edit the current crontabfile using the text editor specified by the EDITOR environment variable or the VISUAL environment variable
-l List the current crontabfile
-r Remove the current crontabfile
-u Specifies the user's crontabto be manipulated. This is usually used by root to manipulate the crontab of other users or can be used by you to correctly identify the crontab to be manipulated if you have used the su command to assume another identity.

     Table 9.1:  Common Options for crontab Command

To list the current user's crontab, use the -l option for the crontab command.

$ crontab -l
# Daily full export
00 01 * * *     /u01/app/oracle/admin/test/scripts/full_export.sh
# Weekly full hot backup
00 03 * * 0     /u01/app/oracle/admin/common/scripts/hot_backup.sh oss 0
# Nightly incremental hot backup
00 03 * * 1-6   /u01/app/oracle/admin/common/scripts/hot_backup.sh oss 1

Using the -e option for the crontab command, the current user's crontab can be edited. This brings a copy of the crontab up in the default editor.  Then the crontab is edited and when the editor is exited, the crontab command puts your changes in place.

crontab also accepts a file name and uses the specified file to create the crontab file.  Many users prefer to use this option rather than the crontab -e command because it provides a master file from which the crontab is built, thus providing a backup to the crontab.   The following example specifies a file called mycron.tab to be used as the input for crontab.

$ crontab mycron.tab

To delete the current user's crontab, use the -r option.  This removes all jobs from the crontab.

$ crontab -r

As root, you can view or manipulate another user's crontab file using the -u option to specify a username.

# crontab -u oracle '??l

* * * * * touch /tmp/file.txt

# crontab -u oracle -e

 

Alternatively, the root user could use su to act as a user then manipulate their crontab, but using the -u option is often easier.

 

 

 
 
 
Get the Complete Details on
Linux System Management for Oracle DBAs  


The landmark book "Linux for the Oracle DBA: The Definitive Reference" provides comprehensive yet specific knowledge on administering Oracle on Linux.   A must-have reference for every DBA running or planning to run Oracle on a Linux platform.

Buy it for 30% off directly from the publisher.
 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster