How To Set Up Cron Jobs In Lnix

 CRONTAB

What is Crontab?

Crontab is a file which contains the schedule of cron entries to be run and at specified times.

Crontab Commands

           export EDITOR=vi ;to specify a editor to open crontab file.

  1.    crontab -e    Edit crontab file, or create one if it doesn’t already exist.
  2.    crontab -l    crontab list of cronjobs , display crontab file contents.
  3. crontab -r    Remove your crontab file.
  4. crontab -v    Display the last time you edited your crontab file.



Crontab Examples

A line in crontab file like below removes the tmp files from /home/appsolworld/tmp each day at 6:30 PM.

30     18     *     *     *         rm /home/appsolworld/tmp/*

Crontab every hour

This is most commonly used for running cron every hour and executing a command after an interval of one hour.
crontab format every hour is simple to have hour field as *  which runs every hour as the clock switches to new hour.  if you want to run it at the beginning of hour the minute filed needs to be 0 or any other minutes when you want to run it at a specific minute of the hour. 
cron every hour to run at the beginning of the hour.00     *     *     *     *         rm /home/appsolworld/tmp/*

 

cron every hour to run at 15 minute of an hour..

15     *     *     *     *         rm /home/someuser/tmp/*

Crontab every minute

To run cron every minute keep the minutes field as * , as minute changes to new minute cron will be executed every minute.  if you want to run it continuously every hour then the hour field also needs to have value of  * .

*     *     *     *     *         rm /home/appsolworld/tmp/*

if you want to run a script every minute at specific hour, change the value of hour field to specific value such as 11th hour.

*     11     *     *     *         rm /home/appsolworld/tmp/*

 









Comments

Popular posts from this blog

How to drop index and before dropping it how to get the DDL.

PRVG-11250 : The check "RPM Package Manager database" was not performed because

ORA-00257:archiver error, connect internal only until freed

Verifying Daemon “Avahi-Daemon” Not Configured And Running …FAILED (PRVG-1360)

Linux OL7/RHEL7: PRVE-0421 : No entry exists in /etc/fstab for mounting /dev/shm

SKIP DNS RESLOV.CONF CHECK DURING RAC CONFIGURATION

CPU Patch Analysis

How to troubleshoot Long Running Concurrent Request in EBS 12.2

How To Manage Space of The FRA in the Oracle DB

How to write to a CSV file using Oracle SQL*Plus