aws cli 출력 리디렉션

aws cli 출력 리디렉션

aws cli의 출력을 로그 파일에 저장하려고 합니다. 어느 정도 효과가 있습니다. 문제는 아래에 공유된 첫 번째 명령을 실행하면 출력이 파일에 저장되지만 두 번째 명령이 실행되면 첫 번째 명령의 출력이 삭제되고 두 번째 명령의 새 출력만 추가된다는 것입니다.

두 명령의 출력을 동일한 로그 파일에 저장하도록 도와주세요.

#!/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

출력을 로그 파일로 리디렉션할 때 두 번째 줄에 >만 추가하면 됩니다. 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}"재설정하는 대신 두 번째 로그 줄을 로그 파일에 추가합니다.

관련 정보