Show Menu
Cheatography

Cron Job and Logrotate Cheat Sheet (DRAFT) by

Cron Job and Logrotate

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Config and Schedule

Cron job script
/etc/c­ron.da­ily­/lo­grotate
Config file
/etc/logrotate.conf
/etc/logrotate.d/
More frequent
a. /etc/cron.hourly
b.crontab (see below)
At what time
cron.daily
runs?
grep run-parts /etc/c­rontab

Cron Job Definition

# .----------- minute (0 - 59)
# | .--------- hour (0 - 23)
# | | .------- day of month (1 - 31)
# | | | .----- month (1 - 12)
# | | | | .--- day of week (0 - 6) (Sun=0 or 7)
# | | | | |
# * * * * * command to be executed

crontab

list
crontab -l
// current user specific
create
crontab -e
// current user specific
user's crontab file
// DON'T edit it directly
CentOS:/var/spool/cron/$user
Ubuntu:/var/spool/cron/crontabs/$user
system­-wide crontable file
// Username is required in this file
/etc/c­rontab
 

Debug Logrotate

status
cat /var/l­ib/­log­rot­ate­/status
mannually run
logrotate -f $CONFI­G_FILE
dry run
logroate -d $CONFI­G_FILE