2 thoughts on “How to set up Cron Jobs for Maintaining Your Linux System

  1. You might want to know about

    # crontab -e -u student

    wich starts the system editor and edits the crontab file with it.
    it’s easyer that recreating the file over and over again.
    you can use the editor of your liking by modifying $EDITOR like

    # declare -x EDITOR=”/usr/bin/nano”

  2. The steps presented here for editing a Linux crontab file do not follow the recommended practice and should be avoided. According to the man pages for many distributions of Linux, crontab(1) should be used for making any changes to crontab files. For example, this is for ISC Cron:

    (from http://linux.die.net/man/1/crontab):
    Crontab is the program used to install, deinstall or list the tables used to drive the cron(8) daemon in ISC Cron. Each user can have their own crontab, and though these are files in /var/spool/ , ***[they are not intended to be edited directly]***.

    (emphasis mine)

    (and this is from http://manpages.ubuntu.com/manpages/maverick/man1/crontab.1.html):
    crontab is the program used to install, deinstall or list the tables
    used to drive the cron(8) daemon in Vixie Cron. Each user can have
    their own crontab, and though these are files in
    /var/spool/cron/crontabs, they are not intended to be edited directly.

    In other words, placing crontab files in the directories where they usually live, as suggested in this article, is not recommended. It may not even work on certain distributions of Linux, as can be seen by the different directories listed in the two man page excerpts above. Instead, use the crontab command itself to install the new crontab file, as stated in the man pages.

    But the simpler way, also recommended in the crontab man pages, is to use the -e option to the crontab command:

    (from https://help.ubuntu.com/community/CronHowto):
    To use cron, simply add entries to your crontab file. To do this, open a terminal window and enter crontab -e. An editor will open displaying your current crontab file. Edit the crontab using the format described below. Then save your changes and your new crontab will be installed. Exiting without saving will leave your crontab untouched.

    -F.M.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.