Logrotate and Cron Job Cheat Sheet

A Software › Linux cheat sheet in English by Architect Handbook
11,749 views 3,653 downloads 15 Sep 2016 History
4.9 avg · 2 ratings

Configure and Schedule

Cron job script
/etc/c­ron.da­ily­/lo­groate
Config­uration file
/etc/l­ogr­ota­te.conf
Hourly or customized
a. /etc/c­ron.hourly
b. crontab (see below)
1. When does cron.daily run? grep run-parts /etc/c­rontab

Cron job definition

# Example of 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
crontab -l // Current user specific
create crontab
crontab -e // Current user specific
user's crontab file
// DON'T edit directly
CentOS­:/v­ar/­spo­ol/­cro­n/$user
Ubuntu /var/s­poo­l/c­ron­/cr­ont­abs­/$user
system­-wide crontab
// Username field is required
/etc/c­rontab
Example (arix-be)
# do daily/­wee­kly­/mo­nthly mainte­nance
# min hour day month weekday command
*/15 * * * * run-parts /etc/p­eri­odi­c/15min
0 * * * * run-parts /etc/p­eri­odi­c/h­ourly
0 2 * * * run-parts /etc/p­eri­odi­c/daily
0 3 * * 6 run-parts /etc/p­eri­odi­c/w­eekly
0 5 1 * * run-parts /etc/p­eri­odi­c/m­onthly

Badges

Nice Cheat Sheet Good Cheat Sheet

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.