Strange crontab-problem

From: Joachim Smit (joachimsmit_at_yahoo.com)
Date: 10/10/05

  • Next message: John L Fjellstad: "Re: 2.6.12 and 2.6.13 won't access cdrom"
    Date: Mon, 10 Oct 2005 10:43:57 -0700 (PDT)
    To: debian-user@lists.debian.org
    
    

    Because some naughty boys try to get in one of my
    clients' Debian-server a couple of hundred times a day
    I decided to shut down sshd when I don't need. With a
    simple mechanisme I can start sshd from distance
    whenever I want.

    Just in case I might forget to close it when I'm
    ready, I run the following script 4 times a day:

    ================

    #!/bin/sh

    DATE="/bin/date"
    DATUM=$($DATE +"%Y-%m-%d-%H:%M")
    SUBJECT="HOL/"$DATUM

    AANTAL=`ps -ef | /bin/grep '/usr/sbin/sshd' |
    /usr/bin/wc -l`

    if [ $AANTAL -ne 0 ] ; then

      /etc/init.d/ssh stop
      /usr/bin/mail joachimsmit@yahoo.com -s $SUBJECT <
    /usr/local/sbin/txt/uittekst
      
    fi

    ==========================

    The strange thing is that when I run the script
    interactive, it doesn't try to shut down sshd when
    it's not active.

    But when I call the script from crontab it ALWAYS
    sends me an email, in other words, $AANTAL is always
    greater than 0. When I echo the value of $AANTAL I see
    that running from crontab it is always 1, running the
    script interactive it is always 0 (if sshd is not
    active)

    Why is there a difference between interactive and
    cron?

    Kind regards,

    Joachim

                    
    __________________________________
    Yahoo! Music Unlimited
    Access over 1 million songs. Try it free.
    http://music.yahoo.com/unlimited/

    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: John L Fjellstad: "Re: 2.6.12 and 2.6.13 won't access cdrom"

    Relevant Pages

    • Some new SSH exploit script?
      ... My SSHd is getting HAMMERED today, ... Download FREE whitepaper on how a managed service can ...
      (Pen-Test)
    • Re: How to start rc script after sshd starts?
      ... What is the recommended way to get this script to start after sshd has ... matters, the daemon is smokeping. ... Another option is to create a dummy script: ...
      (freebsd-stable)
    • Re: SSH Solaris
      ... and just call an external script to send you ... If you are not running the sshd ... managed by inetd. ... First, each connection is a new instance of the sshd daemon, so it ...
      (comp.security.ssh)
    • Re: Strange crontab-problem
      ... > clients' Debian-server a couple of hundred times a day ... > I decided to shut down sshd when I don't need. ... I run the following script 4 times a day: ... > But when I call the script from crontab it ALWAYS ...
      (Debian-User)
    • Re: [PATCH] Re: /etc/rc.d/sshd : "kldload random" missing?
      ... >>which sshd depends on (and others if they're found ... > script already.. ... Do You Yahoo!? ... Mail has the best spam protection around ...
      (freebsd-stable)