Professional Web Applications Themes

cron & leafnode - Ubuntu

* Richard G. Riley wrote in alt.os.linux.ubuntu: > I'm having some issues with leafnode. > slrn is connected and if I "sudo fetchnews" manually everything is ok. > There is a leafnode file in /etc/cron.d > According to the man page this should be picked up & processed by > cron. > However there appears to be no automatic/scheduled call to > fetchnews. Any ideas? Logs to check? > The leafnode in cron.d is: > 8 * * * * news if [ -x /etc/news/leafnode/do-fetch-news ]; then /etc/news/leafnode/do-fetch-news; fi Here is mine in my root crontab rootgates-of-hell:/home/sinner # crontab -e ...

  1. #1

    Default Re: cron & leafnode

    * Richard G. Riley wrote in alt.os.linux.ubuntu:
    > I'm having some issues with leafnode.
    > slrn is connected and if I "sudo fetchnews" manually everything is ok.
    > There is a leafnode file in /etc/cron.d
    > According to the man page this should be picked up & processed by
    > cron.
    > However there appears to be no automatic/scheduled call to
    > fetchnews. Any ideas? Logs to check?
    > The leafnode in cron.d is:
    > 8 * * * * news if [ -x /etc/news/leafnode/do-fetch-news ]; then /etc/news/leafnode/do-fetch-news; fi
    Here is mine in my root crontab
    rootgates-of-hell:/home/sinner # crontab -e

    0,10,20,30,40,50 * * * * /usr/local/sbin/fetchnews

    Fetchnews runs every 10 minutes every day.
    --
    David
    By rule #1, 5.005 should always allow localization of lexical _ . . .
    -- Larry Wall in <199710011704.KAA21395wall.org>
    SINNER Guest

  2. #2

    Default Re: cron & leafnode

    * Richard G. Riley wrote in alt.os.linux.ubuntu:
    > "SINNER"posted the following on 2006-03-05:
    >> * Richard G. Riley wrote in alt.os.linux.ubuntu:
    >>> I'm having some issues with leafnode.
    >>> slrn is connected and if I "sudo fetchnews" manually everything is ok.
    >>> There is a leafnode file in /etc/cron.d
    >>> According to the man page this should be picked up & processed by
    >>> cron.
    >>> However there appears to be no automatic/scheduled call to
    >>> fetchnews. Any ideas? Logs to check?
    >>> The leafnode in cron.d is:
    >>> 8 * * * * news if [ -x /etc/news/leafnode/do-fetch-news ]; then /etc/news/leafnode/do-fetch-news; fi
    >> Here is mine in my root crontab
    >> rootgates-of-hell:/home/sinner # crontab -e
    >> 0,10,20,30,40,50 * * * * /usr/local/sbin/fetchnews
    >> Fetchnews runs every 10 minutes every day.
    > I have to "sudo crontab -u root -e" to get something similar to
    > work. Doesn't fetchmail have to run as root?
    Yes. If I absolutely must be root to do something:

    sudo su -

    Do what I need and log out, in this case a simple

    crontab -e

    --
    David
    Vegetarians beware! You are what you eat.
    SINNER Guest

  3. #3

    Default Re: cron & leafnode

    Richard G. Riley wrote:
    > I'm having some issues with leafnode.
    >
    > slrn is connected and if I "sudo fetchnews" manually everything is ok.
    >
    > There is a leafnode file in /etc/cron.d
    >
    > According to the man page this should be picked up & processed by
    > cron.
    >
    > However there appears to be no automatic/scheduled call to
    > fetchnews. Any ideas? Logs to check?
    >
    > The leafnode in cron.d is:
    >
    > 8 * * * * news if [ -x /etc/news/leafnode/do-fetch-news ]; then
    > /etc/news/leafnode/do-fetch-news; fi
    >
    >
    > I have checked do-fetch-news exists.
    >
    > I'm stumped.
    Did you look at do-fetch-news (it's a script) to see what it does? If you
    did you would see that references a file like this:

    # Get configuration
    .. /etc/news/leafnode/debian-config

    So looking in the /etc/news/leafnode/debian-config file you find the
    following:

    # DO NOT MODIFY THIS FILE BY HAND - use 'dpkg-reconfigure leafnode' to
    # modify it instead. The package will overwrite this file with the
    # options selected using debconf whenever the postinst script is run.

    # What sort of network connection do we have? Valid values are PPP,
    # permanent and none.
    NETWORK=permanent

    Now a picture is forming. OK, go back and look at the logic in
    do-fetch-news:

    if [ "$NETWORK" = "permanent" -a -x /usr/sbin/fetchnews ]; then
    /usr/sbin/fetchnews
    fi

    AH! Bingo!! If the $NETWORK variable from debian-config is *NOT* "permanent"
    then /usr/bin/fetchnews will never get executed, the do-fetch-news script
    will gracefully fall through and nothing will be logged except that cron
    ran the do-fetch-news script as instructed :)

    So run "sudo dpkg-reconfigure leafnode" and change your network to
    permanent :) If you don't have a network connection, cron will send root a
    message with all the complaints from fetchnews.

    Personally, I ditched the cron entry for do-fetch-news, and instead replaced
    it with the following:

    ----- sync-news.sh -----
    #!/bin/bash

    # define some variables
    CONFIG=/etc/news/leafnode/config
    SERVER=`egrep -vi '^#|^$' $CONFIG | grep -m 1 server | \
    awk -F= '{ print $NF }' | sed s/\ //g`

    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/adminscripts

    testnet(){
    ping -c 1 $SERVER &> /dev/null
    echo $?
    }

    if [[ `testnet` -eq 0 ]]; then
    # network is up and we can reach the news server
    /usr/sbin/fetchnews;
    fi
    ----- sync-news.sh -----

    Make it executable (sudo chmod 0744 sync-news.sh), make root own it (sudo
    chown root:root sync-news.sh) and replace "do-fetch-news" in your crontab
    with "/path/to/sync-news.sh". Voila! Now it doesn't matter what damn
    connection you have, it will only do a fetchnews run if the server is
    pingable :)

    Beware - not all news servers can be pinged. Depends entirely on whether or
    not the admins allow ICMP traffic. If your news feed doesn't respond to
    pings install the "hping3" package and use the following testnet()
    function:

    testnet(){
    hping3 $SERVER -c 1 --tcpexitcode -p 119 -S &>/dev/null
    echo $?
    }

    Now change the if statement to this:

    if [[ `testnet` -eq 18 ]]; then

    The reason is that hping3 with the --tcpexitcode will return the tcpflag
    from the ping: 18=SYN+ACK - ie, NNTP is up on $SERVER (20=RESET+ACK - ie,
    received our packet but service is down, and 1=program error, like network
    unreachable). So the ONLY response from hping3 we're interested in is TCP
    status code 18 :)

    Hope all this make some sense :P

    Cheers,

    James
    --
    All models over 18 years of age.

    Centurion Guest

  4. #4

    Default Re: cron & leafnode

    On 2006-03-05, SINNER <99nesorjdgates_of_hell.invalid> wrote:
    > * Richard G. Riley wrote in alt.os.linux.ubuntu:
    >> I'm having some issues with leafnode.
    >
    >> slrn is connected and if I "sudo fetchnews" manually everything is ok.
    >
    >> There is a leafnode file in /etc/cron.d
    >
    >> According to the man page this should be picked up & processed by
    >> cron.
    >
    >> However there appears to be no automatic/scheduled call to
    >> fetchnews. Any ideas? Logs to check?
    >
    >> The leafnode in cron.d is:
    >
    >> 8 * * * * news if [ -x /etc/news/leafnode/do-fetch-news ]; then /etc/news/leafnode/do-fetch-news; fi
    >
    > Here is mine in my root crontab
    > rootgates-of-hell:/home/sinner # crontab -e
    >
    > 0,10,20,30,40,50 * * * * /usr/local/sbin/fetchnews
    >
    > Fetchnews runs every 10 minutes every day.
    Whilst we're here skinning these cats:

    *\10 * * * * /usr/sbin/fetchnews -f >> /var/log/crontablog 2>&1

    Fetchnews runs every 10 minutes, and creates an ever-growing pointless log file
    too. That's added value :)

    --
    -Toby, who...
    Add the word afiduluminag to the subject
    field to cirvent my email filters.
    Ignore any mail delivery error.
    Toby Newman Guest

  5. #5

    Default Re: cron & leafnode

    * Toby Newman wrote in alt.os.linux.ubuntu:
    > On 2006-03-05, SINNER <99nesorjdgates_of_hell.invalid> wrote:
    >> * Richard G. Riley wrote in alt.os.linux.ubuntu:
    >>> I'm having some issues with leafnode.
    >>> slrn is connected and if I "sudo fetchnews" manually everything is ok.
    >>> There is a leafnode file in /etc/cron.d
    >>> According to the man page this should be picked up & processed by
    >>> cron.
    >>> However there appears to be no automatic/scheduled call to
    >>> fetchnews. Any ideas? Logs to check?
    >>> The leafnode in cron.d is:
    >>> 8 * * * * news if [ -x /etc/news/leafnode/do-fetch-news ]; then /etc/news/leafnode/do-fetch-news; fi
    >> Here is mine in my root crontab
    >> rootgates-of-hell:/home/sinner # crontab -e
    >> 0,10,20,30,40,50 * * * * /usr/local/sbin/fetchnews
    >> Fetchnews runs every 10 minutes every day.
    > Whilst we're here skinning these cats:
    > *\10 * * * * /usr/sbin/fetchnews -f >> /var/log/crontablog 2>&1
    Ha! Love it. Thanks! Nothing really bought here other than keystrokes
    thought right? I mean, its not an efficiency thing is it?
    > Fetchnews runs every 10 minutes, and creates an ever-growing pointless
    > log file too. That's added value :)
    No thanks! It already gets logged and sends me mail!

    :)
    --
    David
    If I had only known, I would have been a locksmith.
    -- Albert Einstein
    SINNER Guest

Similar Threads

  1. cron job
    By cljlk in forum Linux / Unix Administration
    Replies: 1
    Last Post: April 2nd, 06:50 PM
  2. rsh and cron
    By cljlk in forum Linux / Unix Administration
    Replies: 2
    Last Post: November 14th, 03:20 PM
  3. cron
    By Richard Lynch in forum PHP Development
    Replies: 0
    Last Post: August 15th, 05:14 PM
  4. Cron Not Restarted
    By Adam Williams in forum AIX
    Replies: 1
    Last Post: August 7th, 04:25 PM
  5. Help with Leafnode filters
    By Subba Rao in forum Linux Setup, Configuration & Administration
    Replies: 6
    Last Post: July 5th, 12:44 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139