Re: Cron job question

From: Matthew Seaman (m.seaman_at_infracaninophile.co.uk)
Date: 08/22/03

  • Next message: Rick Hoekman: "Re[2]: Cron job question"
    Date: Fri, 22 Aug 2003 18:41:59 +0100
    To: Rick Hoekman <rick@paranoia.nl>
    
    
    

    On Fri, Aug 22, 2003 at 07:18:16PM +0200, Rick Hoekman wrote:
    > I am getting this message every 5 minutes. Can somebody explain to me
    > why root apparently is not found here?
    >
    >
    > X-Original-To: root@somedomain.nl
    > Delivered-To: root@hoekmansysteembeheer.nl
    > From: root@somedomain.nl (Cron Daemon)
    > To: root@hoekmansysteembeheer.nl
    > Subject: Cron <root@somedomain> root /usr/libexec/atrun
    > X-Cron-Env: <SHELL=/bin/sh>
    > X-Cron-Env: <PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin>
    > X-Cron-Env: <HOME=/root>
    > X-Cron-Env: <LOGNAME=root>
    > X-Cron-Env: <USER=root> Date: Fri, 22 Aug
    > 2003 19:05:00 +0200 (CEST) root: not found
    >

    You've made the classic mistake of confusing the system crontab
    (/etc/crontab) and the user specific crontabs that live in
    /var/cron/tabs. These are quite different files.

    The system crontab /etc/crontab is not user specific: thus it has an
    extra column defining which user ID the command should be run as. In
    general you shouldn't need to touch this file at all -- it's where
    standard stuff like the 'at' queue, newsyslog and the
    daily/weekly/monthly periodic functions are run from. If you must
    alter this file, just edit it directly: cron(8) will pick up the
    changes in a minute or so. In particular you do not need to use
    crontab(1) to manage this file.

    The per-user crontabs are what you would expect if you're familiar
    with the SysV or Linux style cron(8) daemon. Each user has their own
    crontab file, which is managed using the crontab(1) command. In
    general it's a good policy to use the per-user crontab stuff to add
    any new cron jobs for any user (including root) and leave the system
    /etc/crontab in it's default state.

    The error you're seeing suggests to me that what you've done is run
    crontab(1) on /etc/crontab, and the extra column containing the userid
    is being interpreted as a command that cron should run. However,
    there is no command 'root', hence the error message. To fix, make
    sute that /etc/crontab contains the default contents by copying over
    /usr/src/etc/crontab or running mergemaster(1). Backup and delete the
    root crontab you've generated:

        # crontab -l -u root > /tmp/root.crontab
        # crontab -r -u root

    Now, if root.crontab contains substantively the same as /etc/crontab,
    you're done. Otherwise, if you need to add some extra root cron jobs,
    edit /tmp/root.crontab to strip out the default stuff, leaving only
    you extra jobs. Don't put a username in column 6 of the file: rather
    that should be the last column and contain the command to run, as per
    crontab(5). Once edited to your liking load the new crontab file into
    the system:

        # vi /tmp/root.crontab
        # crontab -u root /tmp/root.crontab

            Cheers,

            Matthew

    -- 
    Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                          Savill Way
    PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
    Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
    
    



  • Next message: Rick Hoekman: "Re[2]: Cron job question"

    Relevant Pages

    • [Fwd: OpenBase SQL multiple vulnerabilities Part Deux]
      ... # Writing to roots crontab seems to be fairly prompt at handing out root shells ... This ensures that cron is running when the fake root crontab is created. ... the OpenBase family of products have been enabling some of the most innovative business applications ...
      (Bugtraq)
    • Re: Running DBI, ODBC in the crontab
      ... Run the following lines in both the command line and crontab: ... Any of the paths that are missing in cron ... This communication is issued by UBS AG or an affiliate by the ...
      (perl.dbi.users)
    • SUMMARY: cron entry: nth day of every month?
      ... cron can not handle this with its own syntax. ... 21st but "command" only runs if the output of the "date" command ... What I would suggest is rather than embedding the logic in each script ... The answer is it is _not_ possible to control it only with crontab ...
      (Tru64-UNIX-Managers)
    • [opensuse] Why doesnt this work?
      ... Chain OUTPUT ... the messages log shows that cron executed the OFF.sh shell as ... the crontab entries for root commanded but the iptables dump for the ... makes no difference if the command is run from a script or directly from ...
      (SuSE)
    • Re[2]: Cron job question
      ... MS> extra column defining which user ID the command should be run as. ... MS> crontab file, which is managed using the crontabcommand. ... MS> any new cron jobs for any user (including root) and leave the system ...
      (freebsd-questions)