The cron job is allowed to run the command or script as per the schedule time as per requirement. A cron job is a scheduled task in the Linux flavor which executes after a certain time interval. For example the cron is used to generate the backup for mysql, hosting account or to send E-mails. By default the daemon process is configured for the cron job service, so that when ever server rebooted, crond service will started automatically and execute the cron as per the scheduled time. The cron service scans the file /etc/crontab every minute and it checks in an every line and once cron service triggers as per scheduled crons time/date information.
If the time/date is equal, then the cron job command will be executed. The main configuration file for cron, /etc/crontab, contains the following lines.
root@[~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# 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
If any reason the cron jobs are stopped to working the first check the service status of crond
service by running the following commands
service crond status
or
/etc/init.d/crond status
If the crond service is stopped, then starts it by using the following command from the shell or
from the whm.
service crond start
or
/etc/init.d/crond start
To list the cron jobs for the particular user refer to the command, it will show the cron set under
the particular user with the detail of time and commands.
crontab -l -u user_name
To edit the cron jobs for the paricular user refer to the command
crontab -e -u username
Once cron job setup completed make sure that cron job is running without any problem. We can
check the cron logs under the /var/log/cron file.