Linux - crontab

From Ever changing code
Jump to navigation Jump to search

RHEL8

cat /etc/crontab 
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


Cron's locations

/var/spool/cron is where the individual user crontabs live. As user, crontab -e edits the corresponding file in /var/spool/cron.


/etc/cron.d is a directory that is scanned for modular crontab files. The syntax is slightly different for files in that directory. The cron entries have an additional field for a user to run the cron entries as. This is the same as a systemwide /etc/crontab file.


Adding that the files in /etc/cron.d/ are, in effect, all root-owned (and therefore not user cron files); also, these files are NOT run by cron - they are run by a cron job that looks at these files.