Cron Manual



Files

  • “username” user’s cron file location
    /var/spool/cron/{username}
  • Root’s crontab file
    /var/spool/cron/root
  • Configuration file for cron,
    /etc/crontab

Cron service

service crontd status
service crontd start
service crontd stop
service crontd restart

Valid values for cron job

  • Minutes – from 0 to 59
  • Hours – from 0 to 23
  • Day of month – from 1 to 31
  • Month – from 1 to 12 (also from jan to dec)
  • Day of week – from 0 to 6 (0 is sunday, also from sun to sat)

Cron monitoring commands

  • Check cron config
    chkconfig --list | grep crond
    ps -ef | grep cron
  • Show current cron jobs of user
    crontab -l
  • Show current cron jobs of user root
    crontab -u root -l
  • Delete cur cron jobs
    crontab -r
  • Delete user’s cur cron jobscrontab -u root -r
  • Edit the cron tab jobscrontab -e
  • Edit the user’s cron tab jobs
    crontab -u root -e
  • Install cron job for user root from file /var/spool/cron/root content
    crontab -i -u root /var/spool/cron/root

Example of cron file

# Cron example file /var/spool/cron/root
# (Created for Boot1935)
SHELL=/bin/bash
MAILTO=root

# 1-12 hours
* 0,1,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * * /root/reich3/saytime.sh
# minutes with 5 minute interval
5,10,15,20,25,30,35,40,45,50,55 * * * * /root/reich3/saytime.sh
# hours 0-1, 9-23
* 0-2,9-23 * * * play /root/reich3/saytime.wav
# every minute
0-59 * * * * /root/reich3/saytime.sh

 

Leave a Reply

Your email address will not be published. Required fields are marked *