Equivalent date commands (FreeBSD and GNU/Linux)

I had to put dates in a string in BASH and I had this script on Linux.
The command was something like this:

echo from=`date -d "last month" +%m/01/%Y`\&to=`date -d "$(date +%Y-%m)-01 yesterday" +%m/%d/%Y`

The above did not work on FreeBSD so I had to modify it:

echo from=`date -v-1m +%m/01/%Y`\&to=`date -v-1d -j $(date +%Y%m)010101 +%m/%d/%Y`

What the above commands do is make from = “first day of last month” and to = “last day of last month.”

 

More simply, to print the first day of last month in Linux:

# date -d "last month" +%m/01/%Y
07/01/2018

and in FreeBSD

# date -v-1m +%m/01/%Y
07/01/2018

To print the last day of last month in Linux:

# date -d "$(date +%Y-%m)-01 yesterday" +%m/%d/%Y
07/31/2018

and in FreeBSD:

# date -v-1d -j $(date +%Y%m)010101 +%m/%d/%Y
07/31/2018

Setting up java for ec2-api-tools on Fedora Linux

Download the Linux or Linux 64 package (not the RPM) from Oracle at http://java.com/en/download/manual.jsp

As root:

mkdir /usr/java

since it probably does not exist by default.

Extract the jre-7u21-linux.tar.gz file you downloaded into /usr/java

cd /usr/java && tar xzf jre-7u21-linux.tar.gz

You will have something like:

/usr/java/jre1.7.0_21/

So in your .bashrc file (or however you set up your environmental variables for EC2) add:

export JAVA_HOME=/usr/java/jre1.7.0_21/

Resources:
http://blog.serverdensity.com/installing-ec2-api-tools-on-fedora/