[PLUG] Cron advice needed

Martin A. Brown martin at linux-ip.net
Sat Apr 23 07:03:02 UTC 2016


Hello,

>> where in Cron do I place this command?

This is a good question and is puzzling to anybody who doesn't 
already know how cron works.

>> How does the command line know I am calling Cron?

And, a bit of misconception here.  I'll explain some below, 
exactly as Paul Mullen has also already provided an answer (try out 
the 'crontab' command. and has also unpacked the format of the cron 
one-liner.

Some things to know about cron on the typical Linux system.

  * This is a venerable pan-Unix root-run program that is typically 
    run at boot.  In short, it is a common system daemon.

  * The most well-known configuration file is called /etc/crontab.  

  * Some Linux distributions (especially ones built on packaging 
    systems) have created directories to allow people to drop full
    scripts in.  For example, you might find /etc/cron.daily/ or 
    /etc/cron.weekly/ populated with maintenance scripts to rotate
    the system logs or keep the 'slocate' or 'mlocate' database 
    updated.

    The files in /etc/cron.{daily,weekly,monthly} are usually 
    owned by a package or installed by an administrator (you, if 
    it's your machine).

  * Similarly, you may find a directory called /etc/cron.d/ which 
    can contain entire files containing crontab-formatted lines.

    The files in /etc/cron.d/ are also (typically) owned by a 
    package or installed by an administrator.

  * What's missing?  User-level support!  In addition to executing 
    jobs periodically according to the /etc/crontab (and friends), 
    the 'cron' daemon will also watch a specific directory which 
    contains user-level entries.

    The directory containing the user-level crontabs is usually 
    found underneath /var/spool/cron.  For example on an Ubuntu 
    system it's at /var/spool/cron/crontabs and on an OpenSUSE 
    system, it's /var/spool/cron/tabs.

    You might not be able to see inside the /var/spool/cron 
    directory as an unprivileged user.

  * When, you as a user, run 'crontab -e' and add an entry, your
    entry gets stored in the user-level crontab area.

    You can list your personal crontab with 'crontab -l'.

Note:

  * There is a slight difference between the crontab entry format
    useable for system-level entries (i.e. /etc/crontab, 
    /etc/cron.d/) and user-level entries.

    System-level entry (must specify user):

    1,31  *  *  *  * username $HOME/zeug/tickle-fetchmail

    User level entry (no user specified):
    
    1,31  *  *  *  * $HOME/zeug/tickle-fetchmail

Good luck and happy trails,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/



More information about the PLUG mailing list