Skip to content

Commit

Permalink
TM-815 - create cron job file via userdata
Browse files Browse the repository at this point in the history
Signed-off-by: Fani Foteva <[email protected]>
  • Loading branch information
Fani Foteva committed Dec 12, 2024
1 parent 9d68cce commit 447d4b3
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions terraform/environments/edw/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,89 @@ mkdir -p /home/oracle/scripts
sudo /etc/init.d/iptables stop
sudo /sbin/chkconfig iptables off
# Install mailx
sudo yum install -y mailx
sudo ln -s /bin/mail /bin/mailx
# Configure maat db cron job script:
# Create the maat_05365_ware_db_changes.sh script
cat << 'EOC22' > /home/oracle/scripts/maat_05365_ware_db_changes.sh
#!/bin/ksh
# fixed variables
chown -R oracle:dba /home/oracle/scripts
LOCATE=/home/oracle/scripts
ORACLE_SID=$1; export ORACLE_SID
ORACLE_HOME=/oracle/software/product/10.2.0; export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH; export PATH
cd $LOCATE
sqlplus -s /nolog <<eosql >rundatafix.log
conn warehouse/whouse_prod
@maat_05365_ware_db_changes.sql
exit
eosql
# mailx -s "MI Production (EDW005) datafix 3079 \`date\`" [email protected] < rundatafix.log
EOC22
# Create the maat_05365_ware_db_changes.sql script
cat << 'EOC23' > /home/oracle/scripts/maat_05365_ware_db_changes.sql
--------------------------------------------------------------------------------------------------------------------
--
-- Archive: %ARCHIVE%
-- Revision: %PR%
-- Date: %DATE%
--
-- Purpose: Modify warehouse tables to set column default values
--
--
-- Dimensions History
-- ------------------
--
-- Ver Date Name Description
-- ---- -------- -------------------- ------------------------------------------------------------------------------
-- 1.0 27/11/14 H Khela Initial Version
--
--
--------------------------------------------------------------------------------------------------------------------
SPOOL maat_05365_ware_db_changes.log
-- Set time on so you can see how long each part takes
SET TIME ON
-- Set echo on so that you can see which command it is executing (and the time)
SET ECHO ON
ALTER TABLE warehouse.maat_assessment_fact MODIFY (
time_eff_to_dim_id NUMBER DEFAULT NULL);
ALTER TABLE warehouse.maat_application_dim MODIFY (
time_eff_to_dim_id NUMBER DEFAULT NULL);
-- 9710356 rows updated.
UPDATE warehouse.maat_assessment_fact
SET time_eff_to_dim_id = NULL
WHERE time_eff_to_dim_id = -1;
COMMIT;
-- 4558089 rows updated
UPDATE warehouse.maat_application_dim
SET time_eff_to_dim_id = NULL
WHERE time_eff_to_dim_id = -1;
COMMIT;
SPOOL OFF
EOC23
# Set up log files
echo "---creating /etc/awslogs/awscli.conf"
mkdir -p /etc/awslogs
Expand Down

0 comments on commit 447d4b3

Please sign in to comment.