Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6AB4F200BFB for ; Wed, 11 Jan 2017 16:01:30 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 69B69160B4E; Wed, 11 Jan 2017 15:01:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1BE02160B2E for ; Wed, 11 Jan 2017 16:01:28 +0100 (CET) Received: (qmail 70845 invoked by uid 500); 11 Jan 2017 15:01:27 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 70835 invoked by uid 99); 11 Jan 2017 15:01:27 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Jan 2017 15:01:27 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 07DDA1A0737 for ; Wed, 11 Jan 2017 15:01:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.679 X-Spam-Level: * X-Spam-Status: No, score=1.679 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id jXFH3wU1sI6W for ; Wed, 11 Jan 2017 15:01:24 +0000 (UTC) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id A68DE5FDD1 for ; Wed, 11 Jan 2017 15:01:23 +0000 (UTC) Received: by mail-lf0-f54.google.com with SMTP id k86so138625329lfi.0 for ; Wed, 11 Jan 2017 07:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:date:references:to:in-reply-to:message-id; bh=7HaEoKt35Wci3VdGnzw8XgCb/nPwLZz5IXIbZAGb0DA=; b=nUzW5VTPqJaM8o+6VyFKY2JAi0IWWqrIOf4/3JQvWJdKmzdPrCYYxUM5JXhQCzUXmh gWKPT+MvFd65ckuLK/JkkqhJOXi5KxeaRV0YaKRM8N6P0cYCDPIri0+eVeI//Kb6dWAt DhmDERfM2rJ98MLFz3vQb7NuYcv1fH7pOwibGRGYEnpXI2v5kyLfVUKcJRJ7sens6Mm6 ++V63b34zVyFEQaeuXDcANncRbGBLFIeuZSSwm5RVKmIpkSfPsQOikl4JFu6jehmQsbJ I+9W6OFWTP+cnk8DNNE6AuIN9nFpLzKZ09aM0dMK+c8ZwzW4+t+TmfkLVeyVFB4FPb1r c4Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:date:references:to :in-reply-to:message-id; bh=7HaEoKt35Wci3VdGnzw8XgCb/nPwLZz5IXIbZAGb0DA=; b=HDmvCCeIfAaxxk6MycTjwWqMS4cBotrA5k8DyCmG3Lv5c2iodpEiyMnWLj4vwt49FU wAvcGL3J6Ss0m8urDkZjnME439I1l/JTvwXc9idQrSD2I85YwPe3BKwS+tSLmrGSKE4g B9WltpiqEGKlU9TTYuoIhTcZ2T6Hsn5V6fWkceWfCnKE6K19NE4G62Vm9zYicQYEKIWe yOAKCb1tBI8IhUBSIw6Uvw4LicCKLr57PJN23YWUKYEJX2bT2P3iRBX3z9ayovdCmsR4 pO9h+MJP4gWIDl7n/6UCB+T5oa1vT9+PyYGrIhJXZ5XTKTu+i53a9MnCCbpZzHA5l/J7 vbrA== X-Gm-Message-State: AIkVDXIppIqx7LPQVWrJ7axXuxMhwa2R2oEvYLsVwKcNAy4zz7uQZCJa77taNIh8OPExLg== X-Received: by 10.46.72.9 with SMTP id v9mr3291194lja.67.1484146882752; Wed, 11 Jan 2017 07:01:22 -0800 (PST) Received: from [10.0.1.103] (syi-fgw2-1500.syi.inet.fi. [88.194.157.220]) by smtp.gmail.com with ESMTPSA id c75sm1404795lfe.28.2017.01.11.07.01.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 07:01:22 -0800 (PST) From: =?utf-8?Q?Hannu_Kr=C3=B6ger?= Content-Type: multipart/alternative; boundary="Apple-Mail=_42067B79-88FA-4224-9DC9-446BE8CD1584" Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: Re: Strange issue wherein cassandra not being started from cron Date: Wed, 11 Jan 2017 17:01:21 +0200 References: To: user@cassandra.apache.org In-Reply-To: Message-Id: <4DE0D25A-E9C9-4567-BD8A-003299418833@gmail.com> X-Mailer: Apple Mail (2.3259) archived-at: Wed, 11 Jan 2017 15:01:30 -0000 --Apple-Mail=_42067B79-88FA-4224-9DC9-446BE8CD1584 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii One possible reason is that cassandra process gets different user when = run differently. Check who owns the data files and check also what gets = written into the /var/log/cassandra/system.log (or whatever that was). Hannu > On 11 Jan 2017, at 16.42, Ajay Garg wrote: >=20 > Tried everything. > Every other cron job/script I try works, just the cassandra-service = does not. >=20 > On Wed, Jan 11, 2017 at 8:51 AM, Edward Capriolo = > wrote: >=20 >=20 > On Tuesday, January 10, 2017, Jonathan Haddad > wrote: > Last I checked, cron doesn't load the same, full environment you see = when you log in. Also, why put Cassandra on a cron? > On Mon, Jan 9, 2017 at 9:47 PM Bhuvan Rawal > = wrote: > Hi Ajay, >=20 > Have you had a look at cron logs? - mine is in path /var/log/cron >=20 > Thanks & Regards, >=20 > On Tue, Jan 10, 2017 at 9:45 AM, Ajay Garg > = wrote: > Hi All. >=20 > Facing a very weird issue, wherein the command >=20 > /etc/init.d/cassandra start >=20 > causes cassandra to start when the command is run from command-line. >=20 >=20 > However, if I put the above as a cron job >=20 > * * * * * /etc/init.d/cassandra start >=20 > cassandra never starts. >=20 >=20 > I have checked, and "cron" service is running. >=20 >=20 > Any ideas what might be wrong? > I am pasting the cassandra script for brevity. >=20 >=20 > Thanks and Regards, > Ajay >=20 >=20 > = ##########################################################################= ########################## > #! /bin/sh > ### BEGIN INIT INFO > # Provides: cassandra > # Required-Start: $remote_fs $network $named $time > # Required-Stop: $remote_fs $network $named $time > # Should-Start: ntp mdadm > # Should-Stop: ntp mdadm > # Default-Start: 2 3 4 5 > # Default-Stop: 0 1 6 > # Short-Description: distributed storage system for structured data > # Description: Cassandra is a distributed (peer-to-peer) system = for > # the management and storage of structured data. > ### END INIT INFO >=20 > # Author: Eric Evans > >=20 > DESC=3D"Cassandra" > NAME=3Dcassandra > PIDFILE=3D/var/run/$NAME/$NAME.pid > SCRIPTNAME=3D/etc/init.d/$NAME > CONFDIR=3D/etc/cassandra > WAIT_FOR_START=3D10 > CASSANDRA_HOME=3D/usr/share/cassandra > FD_LIMIT=3D100000 >=20 > [ -e /usr/share/cassandra/apache-cassandra.jar ] || exit 0 > [ -e /etc/cassandra/cassandra.yaml ] || exit 0 > [ -e /etc/cassandra/cassandra-env.sh ] || exit 0 >=20 > # Read configuration variable file if it is present > [ -r /etc/default/$NAME ] && . /etc/default/$NAME >=20 > # Read Cassandra environment file. > . /etc/cassandra/cassandra-env.sh >=20 > if [ -z "$JVM_OPTS" ]; then > echo "Initialization failed; \$JVM_OPTS not set!" >&2 > exit 3 > fi >=20 > export JVM_OPTS >=20 > # Export JAVA_HOME, if set. > [ -n "$JAVA_HOME" ] && export JAVA_HOME >=20 > # Load the VERBOSE setting and other rcS variables > . /lib/init/vars.sh >=20 > # Define LSB log_* functions. > # Depend on lsb-base (>=3D 3.0-6) to ensure that this file is present. > . /lib/lsb/init-functions >=20 > # > # Function that returns 0 if process is running, or nonzero if not. > # > # The nonzero value is 3 if the process is simply not running, and 1 = if the > # process is not running but the pidfile exists (to match the exit = codes for > # the "status" command; see LSB core spec 3.1, section 20.2) > # > CMD_PATT=3D"cassandra.+CassandraDaemon" > is_running() > { > if [ -f $PIDFILE ]; then > pid=3D`cat $PIDFILE` > grep -Eq "$CMD_PATT" "/proc/$pid/cmdline" 2>/dev/null && = return 0 > return 1 > fi > return 3 > } > # > # Function that starts the daemon/service > # > do_start() > { > # Return > # 0 if daemon has been started > # 1 if daemon was already running > # 2 if daemon could not be started >=20 > ulimit -l unlimited > ulimit -n "$FD_LIMIT" >=20 > cassandra_home=3D`getent passwd cassandra | awk -F ':' '{ print = $6; }'` > heap_dump_f=3D"$cassandra_home/java_`date +%s`.hprof" > error_log_f=3D"$cassandra_home/hs_err_`date +%s`.log" >=20 > [ -e `dirname "$PIDFILE"` ] || \ > install -d -ocassandra -gcassandra -m755 `dirname $PIDFILE` >=20 >=20 >=20 > start-stop-daemon -S -c cassandra -a /usr/sbin/cassandra -q -p = "$PIDFILE" -t >/dev/null || return 1 >=20 > start-stop-daemon -S -c cassandra -a /usr/sbin/cassandra -b -p = "$PIDFILE" -- \ > -p "$PIDFILE" -H "$heap_dump_f" -E "$error_log_f" >/dev/null = || return 2 >=20 > } >=20 > # > # Function that stops the daemon/service > # > do_stop() > { > # Return > # 0 if daemon has been stopped > # 1 if daemon was already stopped > # 2 if daemon could not be stopped > # other if a failure occurred > start-stop-daemon -K -p "$PIDFILE" -R TERM/30/KILL/5 >/dev/null > RET=3D$? > rm -f "$PIDFILE" > return $RET > } >=20 > case "$1" in > start) > [ "$VERBOSE" !=3D no ] && log_daemon_msg "Starting $DESC" = "$NAME" > do_start > case "$?" in > 0|1) [ "$VERBOSE" !=3D no ] && log_end_msg 0 ;; > 2) [ "$VERBOSE" !=3D no ] && log_end_msg 1 ;; > esac > ;; > stop) > [ "$VERBOSE" !=3D no ] && log_daemon_msg "Stopping $DESC" = "$NAME" > do_stop > case "$?" in > 0|1) [ "$VERBOSE" !=3D no ] && log_end_msg 0 ;; > 2) [ "$VERBOSE" !=3D no ] && log_end_msg 1 ;; > esac > ;; > restart|force-reload) > log_daemon_msg "Restarting $DESC" "$NAME" > do_stop > case "$?" in > 0|1) > do_start > case "$?" in > 0|1) > do_start > case "$?" in > 0) log_end_msg 0 ;; > 1) log_end_msg 1 ;; # Old process is still = running > *) log_end_msg 1 ;; # Failed to start > esac > ;; > *) > # Failed to stop > log_end_msg 1 > ;; > esac > ;; > status) > is_running > stat=3D$? > case "$stat" in > 0) log_success_msg "$DESC is running" ;; > 1) log_failure_msg "could not access pidfile for $DESC" ;; > *) log_success_msg "$DESC is not running" ;; > esac > exit "$stat" > ;; > *) > echo "Usage: $SCRIPTNAME = {start|stop|restart|force-reload|status}" >&2 > exit 3 > ;; > esac >=20 > : >=20 > # vi:ai sw=3D4 ts=3D4 tw=3D0 et > = ##########################################################################= ########################## >=20 >=20 > --=20 > Regards, > Ajay >=20 >=20 > Right. Cron is not a full shell and does not by default source things = like .profile. crons man pages discuss this. >=20 > A shortcut is sometimes=20 > * * * * * /etc/profile & cmd >=20 >=20 >=20 > --=20 > Sorry this was sent from mobile. Will do less grammar and spell check = than usual. >=20 >=20 >=20 > --=20 > Regards, > Ajay --Apple-Mail=_42067B79-88FA-4224-9DC9-446BE8CD1584 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii One possible reason is that cassandra process gets different = user when run differently. Check who owns the data files and check also = what gets written into the /var/log/cassandra/system.log (or whatever = that was).

Hannu

On 11 Jan 2017, at 16.42, Ajay Garg <ajaygargnsit@gmail.com> wrote:

Tried everything.
Every = other cron job/script I try works, just the cassandra-service does = not.

On Wed, Jan 11, 2017 at 8:51 AM, Edward Capriolo = <edlinuxguru@gmail.com> = wrote:


On = Tuesday, January 10, 2017, Jonathan Haddad <jon@jonhaddad.com> wrote:
Last I checked, cron doesn't load the same, full = environment you see when you log in. Also, why put Cassandra on a = cron?
On Mon, Jan 9, 2017 at 9:47 PM Bhuvan Rawal <bhu1rawal@gmail.com> wrote:
Hi Ajay,

Have you had a look at cron logs? - mine is in path = /var/log/cron

Thanks & Regards,

On Tue, Jan 10, 2017 at 9:45 AM, Ajay Garg <ajaygargnsit@gmail.com> wrote:
Hi All.

Facing a very weird issue, wherein the command

/etc/init.d/cassandra = start

causes cassandra to start = when the command is run from command-line.


However, if I put the above as a cron = job

* * * * * = /etc/init.d/cassandra start

cassandra never starts.


I have checked, and "cron" service is = running.


Any ideas = what might be wrong?
I am pasting the cassandra = script for brevity.


Thanks and Regards,
Ajay


####################################################################################################
#! /bin/sh
### BEGIN INIT INFO
# = Provides:          = cassandra
# Required-Start:    $remote_fs = $network $named $time
# = Required-Stop:     $remote_fs $network $named = $time
# Should-Start:      ntp = mdadm
# Should-Stop:       = ntp mdadm
# Default-Start:     2 3 4 = 5
# Default-Stop:      0 1 6
# Short-Description: distributed storage system for = structured data
# = Description:       Cassandra is a = distributed (peer-to-peer) system for
#          &n= bsp;         the management and = storage of structured data.
### END INIT INFO

# Author: Eric Evans <eevans@racklabs.com>

DESC=3D"Cassandra"
NAME=3Dcassandra
PIDFILE=3D/var/run/$NAME/$NAME.pid
SCRIPTNAME=3D/etc/init.d/$NAME
CONFDIR=3D/etc/cassandra
WAIT_FOR_START=3D10
CASSANDRA_HOME=3D/usr/share/cassandra
FD_LIMIT=3D100000

[ -e = /usr/share/cassandra/apache-cassandra.jar ] || exit 0
[ -e /etc/cassandra/cassandra.yaml ] || exit 0
[ = -e /etc/cassandra/cassandra-env.sh ] || exit 0

# Read configuration variable file if it is = present
[ -r /etc/default/$NAME ] && . = /etc/default/$NAME

# Read Cassandra = environment file.
. /etc/cassandra/cassandra-env.sh

if [ -z "$JVM_OPTS" ]; then
    echo "Initialization failed; \$JVM_OPTS = not set!" >&2
    exit 3
fi

export JVM_OPTS

# Export JAVA_HOME, if set.
[ -n = "$JAVA_HOME" ] && export JAVA_HOME

# = Load the VERBOSE setting and other rcS variables
. = /lib/init/vars.sh

# Define LSB log_* = functions.
# Depend on lsb-base (>=3D 3.0-6) to ensure = that this file is present.
. /lib/lsb/init-functions

#
# Function that returns 0 if = process is running, or nonzero if not.
#
# = The nonzero value is 3 if the process is simply not running, and 1 if = the
# process is not running but the pidfile exists (to = match the exit codes for
# the "status" command; see LSB = core spec 3.1, section 20.2)
#
CMD_PATT=3D"cassandra.+CassandraDaemon"
is_running()
{
    = if [ -f $PIDFILE ]; then
        pid=3D`cat = $PIDFILE`
        grep = -Eq "$CMD_PATT" "/proc/$pid/cmdline" 2>/dev/null && return = 0
        return 1
    fi
    return = 3
}
#
# Function that starts = the daemon/service
#
do_start()
{
    # Return
    #   0 if daemon has been = started
    #   1 if daemon was = already running
    #   2 if = daemon could not be started

    ulimit -l unlimited
    ulimit -n "$FD_LIMIT"

    cassandra_home=3D`getent passwd cassandra = | awk -F ':' '{ print $6; }'`
    = heap_dump_f=3D"$cassandra_home/java_`date +%s`.hprof"
    error_log_f=3D"$cassandra_home/hs_err_`date +%s`.log"

    [ -e `dirname "$PIDFILE"` ] || \
        install -d = -ocassandra -gcassandra -m755 `dirname $PIDFILE`



    = start-stop-daemon -S -c cassandra -a /usr/sbin/cassandra -q -p = "$PIDFILE" -t >/dev/null || return 1

    start-stop-daemon -S -c cassandra -a = /usr/sbin/cassandra -b -p "$PIDFILE" -- \
        -p "$PIDFILE" -H = "$heap_dump_f" -E "$error_log_f" >/dev/null || return 2

}

#
#= Function that stops the daemon/service
#
do_stop()
{
    # = Return
    #   0 if daemon has = been stopped
    #   1 if daemon = was already stopped
    #   2 if = daemon could not be stopped
    = #   other if a failure occurred
   = start-stop-daemon -K -p "$PIDFILE" -R TERM/30/KILL/5 >/dev/null
    RET=3D$?
    = rm -f "$PIDFILE"
    return $RET
}

case "$1" in
  start)
        [ "$VERBOSE" !=3D = no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
          &nb= sp;     0|1) [ "$VERBOSE" !=3D no ] && = log_end_msg 0 ;;
          &nb= sp;     2) [ "$VERBOSE" !=3D no ] && = log_end_msg 1 ;;
        = esac
        ;;
  stop)
        [ "$VERBOSE" !=3D = no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
          &nb= sp;     0|1) [ "$VERBOSE" !=3D no ] && = log_end_msg 0 ;;
          &nb= sp;     2) [ "$VERBOSE" !=3D no ] && = log_end_msg 1 ;;
        = esac
        ;;
  restart|force-reload)
        log_daemon_msg = "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          = 0|1)
          &nb= sp;     do_start
          &nb= sp;     case "$?" in
          = 0|1)
          &nb= sp;     do_start
          &nb= sp;     case "$?" in
          &nb= sp;            = ; 0) log_end_msg 0 ;;
          &nb= sp;            = ; 1) log_end_msg 1 ;; # Old process is still running
          &nb= sp;            = ; *) log_end_msg 1 ;; # Failed to start
          &nb= sp;     esac
          &nb= sp;     ;;
          *)
          &nb= sp;     # Failed to stop
          &nb= sp;     log_end_msg 1
          &nb= sp;     ;;
        esac
        ;;
  status)
    is_running
    stat=3D$?
    = case "$stat" in
      0) = log_success_msg "$DESC is running" ;;
      1) log_failure_msg "could not = access pidfile for $DESC" ;;
      = *) log_success_msg "$DESC is not running" ;;
    esac
    exit = "$stat"
    ;;
  *)
        echo "Usage: = $SCRIPTNAME {start|stop|restart|force-reload|status}" = >&2
        exit = 3
        ;;
esac

:

# vi:ai sw=3D4 ts=3D4 tw=3D0 et
####################################################################################################


--
Regards,
Ajay
=
=

Right. Cron is not a full = shell and does not by default source things like .profile. crons man = pages discuss this.

A shortcut is sometimes 
* * * * * = /etc/profile & cmd



--
Sorry this was sent from mobile. Will do = less grammar and spell check than usual.



--
Regards,
Ajay

= --Apple-Mail=_42067B79-88FA-4224-9DC9-446BE8CD1584--