0

I'm trying to save the output of aws cli to the logfile. and it is working to some extent. The issue is that from below shared first commands execute it save output to the file but when second commands runs it delete the first command's output and just append new output which is of second command.

Please help to me save output of both the commands in the same logfile.

#!/bin/sh
#
#set -vx
timestamp=$(date +"%Y-%m-%d-%H-%M-%S")
LOGFILE=/home/ec2-user/POC/restore/my_setup_log_file.$timestamp.log
aws rds restore-db-cluster-from-snapshot --db-cluster-identifier $credit_iden_t --snapshot-identifier $credit_snap_name --engine aurora-mysql --engine-version 5.7.mysql_aurora.2.11.4 --engine-mode serverless --db-subnet-group-name vpc-dbsubnetgroup-1 --vpc-security-group-ids sg-03214e 2> "${LOGFILE}"
aws rds restore-db-cluster-from-snapshot --db-cluster-identifier $task_iden_t --snapshot-identifier $task_snap_name --engine aurora-mysql --engine-version 5.7.mysql_aurora.2.11.4 --engine-mode serverless --db-subnet-group-name vpc-dbsubnetgroup-1 --vpc-security-group-ids sg-03214e 2> "${LOGFILE}"
exit;

1 Answers1

0

Just add one > on the second line when redirecting output to logfile. aws rds restore-db-cluster-from-snapshot --db-cluster-identifier $task_iden_t --snapshot-identifier $task_snap_name --engine aurora-mysql --engine-version 5.7.mysql_aurora.2.11.4 --engine-mode serverless --db-subnet-group-name vpc-dbsubnetgroup-1 --vpc-security-group-ids sg-03214e 2>> "${LOGFILE}" It will append the second line logs to logfile instead of resetting it.

admstg
  • 684