Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started



riyadi.bayu_189799 avatar image
riyadi.bayu_189799 asked Erick Ramirez answered

Changing listen and rpc address with crontab

I'm currently working on a PoC disaster recovery setup in Azure we have a cassandra cluster running on one region. The plan is if the region goes down, we will utilize Azure Site Recovery to failover all machines to the secondary region. I'm well aware that the recommended setup is to have multiple regions rather than a single region. But, well, budget constraints.

So in this setup each region has its own IP set, lets say region A is 10.1.0.x region B is 10.2.0.x

As this means that I need to change the cassandra.yaml file, I created a simple file that runs on startup with crontab that changes the following entries

- seeds:,,

I have no problem with changing the seeds, but for rpc and listen address, I always get an empty value like this


My simple script looks like this

## Get current IP address
LOCALIPADDR=$(ip addr show eth0 | grep 'inet ' | cut -d' ' -f6 | awk '{ print $1}' | cut -d'/' -f1)

## replace cassandra.yaml ip addresses with current IP address
sed -i "0,/^rpc_address:.*/s//rpc_address: $LOCALIPADDR/" /etc/cassandra/conf/cassandra.yaml
sed -i "0,/^listen_address:.*/s//listen_address: $LOCALIPADDR/" /etc/cassandra/conf/cassandra.yaml

and my crontab entry looks like this

@reboot /bin/sh /etc/cassandra/conf/

The script works fine when I run it on bash, but I get the empty rpc and listen address on crontab.

Am I doing the crontab or script wrong? Or are there any method to do this kind of failover short of having a secondary dc?

shell script
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

This isn't a Cassandra issue. It's a shell scripting issue.

I suggest you consult your sysadmin team for assistance. Cheers!

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.