Linux Cron
This post will guide you how to understand cron jobs, and its syntax and how to create an new cron task in your linux operating system.
Cron is a service or daemon to execute a specified command or scripts at a given time or date in your current Linux system. For example, if you want to check the status of the APACHE service every 1 hour, you can create a new cron job using crontab tool to achieve it.
The master config file is located in /etc/crontab, and you can add one cron record into this file to execute your command or scripts at your given time.
You can use the CAT command to check the content of the master file, issue the following command:
#cat /etc/crontab
outputs:
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed
Create Your Own cron job
If you want to create you own cron job in current system, you just need to run the crontab command with -e option, issue the command:
#crontab -e
List cron jobs
if you want to list all cron jobs in your current system, you can run the following command:
#crontab -l
Related Posts
- Linux: Add Jobs to Cron
- Linux: Check Crond Status
- Linux: Start/Restart/Stop Cron Service
- Linux: List All Cron Jobs
- Linux:Change Crontab Email Settings
- Linux: Disable Mail Alert From Cron Jobs
- Linux Anacron (cron.daily, cron weekly, cron.monthly)
- Linux: Run Cron Job When System Reboot or Startup
- Linux: Run PHP Script Using a Cron Job
- Linux: Run Cron Job Every Minute
- Linux: Run Crontab Job Every 10 Minutes