Find the answer to your Linux question:
Results 1 to 5 of 5
hi, I am using 2.6.32-21-server #32-Ubuntu SMP. I am trying to mail to my root account everyday logwatch. So i write to crontab fro my root user cron -l output ...
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    7

    CRON JOB Problem

    hi,

    I am using 2.6.32-21-server #32-Ubuntu SMP.
    I am trying to mail to my root account everyday logwatch. So i write to crontab
    fro my root user

    cron -l

    output

    41 20 * * * root run-parts /etc/cron.daily

    and then put an executable under /etc/cron.daily folder.

    content of executable

    #!/bin/bash

    /usr/sbin/logwatch --range yesterday --mailto my email id


    But the cron scheduler mail at right time but with no content of logwatch. I think i does no run that executable. My executable is ok cause i can run it from command line and if i run "/usr/sbin/logwatch --range yesterday --mailto my email id command then it also mail. I also tried to put shell script then also no effect.

    So can anybody help me what is the problem. I am giving the mail sent my cron sceduler below.


    From my email id Wed Jun 9 20:41:01 2010
    Return-Path: <my email id>
    X-Original-To: root
    Delivered-To: my email id
    Received: by my email id (Postfix, from userid 0)
    id 4A161240CE; Wed, 9 Jun 2010 20:41:01 +0600 (BDT)
    From: my email id (Cron Daemon)
    To: my email id
    Subject: Cron <my email id> root run-parts /etc/cron.daily
    Content-Type: text/plain; charset=ANSI_X3.4-1968
    X-Cron-Env: <SHELL=/bin/sh>
    X-Cron-Env: <HOME=/root>
    X-Cron-Env: <PATH=/usr/bin:/bin>
    X-Cron-Env: <LOGNAME=root>

    Date: Wed, 9 Jun 2010 20:41:01 +0600 (BDT)
    Status: R
    simple headers

    /bin/sh: root: not found


    Regards

    Durjoy

    **** Please note that as i am new to this forum so i cant post any URL so i replace all my email iD as "my email id" above.

  2. #2
    Just Joined!
    Join Date
    May 2010
    Posts
    7
    please help me to sort it out

  3. #3
    Linux User ptkobe's Avatar
    Join Date
    Feb 2008
    Location
    Torres Vedras, PT
    Posts
    274
    have you tried just
    41 20 * * * run-parts /etc/cron.daily
    ?

    I don't know what you meant to achieve with "root run-parts". But you need to run the script as root, put the above on the root cron

    $ sudo crontab -e

    See also man 5 crontab

    Hope it helps
    Luis

  4. #4
    Just Joined!
    Join Date
    May 2010
    Posts
    7
    Thanks Ptkobe for your post.
    My problem solved in different way what i do i just write the command directly in my root crontab.

    # crontab -e
    # 05 00 * * * /usr/sbin/logwatch --range yesterday --mailto root@sibl-bd.com

    and my problem solved. but what i want to know that what is the purpose of cron.daily folder. and how can i use it.


    Regards

    Durjoy

  5. #5
    Linux User ptkobe's Avatar
    Join Date
    Feb 2008
    Location
    Torres Vedras, PT
    Posts
    274
    man cron only has a small reference to the /etc/cron.{daily,weekly,monthly} directories

    https://help.ubuntu.com/community/CronHowto says a bit more

    But the idea is fairly simple. You put a script there and it runs once a day, no?

    It seems the script name may not contain a period (.). Could that be it?

    Also
    "Although cron requires that each entry in a crontab end in a newline character, neither the crontab command
    nor the cron daemon will detect this error. Instead, the crontab will appear to load normally. However, the
    command will never run. The best choice is to ensure that your crontab has a blank line at the end."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...