setup log rotation

Logrotation is available in most Linux distros. If they are missing, you can easily install them. The logrotation main configuration file is located in /etc/logrotate.conf which is the default setting. The config file contains an include statement that pulls in other log configurations located in the /etc/logrotate.d/ directory. When setting up a log rotation, it’s best to add your log rotation configuration in this directory. Here’s a simple configuration in a file called webmon. ...

January 16, 2021 · 1 min · ulysses

cloudformation userdata

Here’s another way to add startup scripts to your instance during creation. UserData: Fn::Base64: !Sub | #cloud-config repo_upgrade: none runcmd: # Cloud init startup script - "bash /root/setup.sh" write_files: # Cloud init startup script - owner: root:root permissions: '0644' path: /root/setup.sh content: | #! /bin/bash -x write_files: # Cloud init startup script - owner: root:root permissions: '0644' path: /root/setup.sh content: | #! /bin/bash -x # run your bash commands here date > log.txt uptime >> log.txt The above script creates a file setup.sh and executes it during instance creation. The output is dumped to log.txt file.

January 15, 2021 · 1 min · ulysses

create instance with alias ip

How to create an instance from a snapshot with alias IP and reserved IPs. #!/bin/bash gcloud beta compute instances create jump-server \ --network-interface=aliases=10.128.1.0/24,private-network-ip=jump-server,subnet=default \ --machine-type=n1-standard-1 \`` --network-tier=PREMIUM \ --maintenance-policy=MIGRATE \ --service-account=xxxxxxxxxxxxx-compute@developer.gserviceaccount.com \ --tags=int-webserver \ --image=debian-10-buster-v20201216 \ --image-project=debian-cloud \ --boot-disk-size=20GB \ --boot-disk-type=pd-standard \ --boot-disk-device-name=jump-server-1 \ --no-shielded-secure-boot \ --shielded-vtpm \ --shielded-integrity-monitoring \ --labels=name=jump-server \ --reservation-affinity=any \ --zone=us-central1-a \ --project=airy-totality-151318 The default command uses –private-network-ip and –subnet options separately. --private-network-ip 10.0.0.24 \ --subnet=default \ But when dealing with aliases, reserved IPs and subnets, use a single –network-interface option instead. ...

January 14, 2021 · 1 min · ulysses

mounting duplicate uuids

While trying to recover a directory from backup, I ran into an issue with duplicate uuids when trying to mount a recovered volume. The problem was the recovered volume had the same uuid as boot. Here’s the original mount command I ran, but I was getting a wrong fs type error. mkdir mount -t xfs /dev/nvme3n1p2 /recover mount: wrong fs type, bad option, bad superblock on /dev/nvme3n1p2, missing codepage or helper program, or other error It turned out to be a duplicated uuid. To get around this problem, I ran -o nouuid. ...

January 12, 2021 · 1 min · ulysses

gcp manually move instance

Here’s how to move a VM instance from one zone to another. Moving an instance will involve destroying the instance from the source zone, and then recreating a replacement instance in the destination zone. To make the move easier, we will use a machine image to recreate the instance. We will also take advantage of the compute and IP address reservations to guarantee that we use the same IP address machine type. Some large machine types are hard to come by. ...

January 10, 2021 · 2 min · ulysses

top shift i

When you run top on Linux with multiple processors, you can have processes with percentages higher than 100%. On a 4 core system, you can have a process that can run as high as 400%. To view it differently, press “shift i” while top is running. This will toggle the Irix mode to off. Pressing it again will turn it on. When the Irix mode is off, it will only show percentages divided by a total number of CPUs. This way, you get a true percentage of a process in a multiple core system. ...

January 8, 2021 · 1 min · ulysses

aws create backup plan

After you created a backup vault, it’s time to create a backup plan. Here are a few examples. aws backup create-backup-plan \ --cli-input-json file://backup-plan.json \ --profile default \ --region us-east-1 File: backup-plan.json { "BackupPlan": { "BackupPlanName": "efs-0123", "Rules": [ { "RuleName": "efs-0123", "TargetBackupVaultName": "efs-vault", "ScheduleExpression": "cron(0 0 ? * * *)", "StartWindowMinutes": 60, "CompletionWindowMinutes": 10080, "Lifecycle": { "DeleteAfterDays": 7 } } ] } } Finally, create a backup selection. aws backup create-backup-selection \ --backup-plan-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx \ --cli-input-json file://backup-selection.json \ --profile poc \ --region us-east-1 File: backup-selection.json ...

January 6, 2021 · 1 min · ulysses

aws create backup vault

Here’s how to create a backup vault in AWS Backup. aws backup create-backup-vault --backup-vault-name my-efs-vault --profile default --region us-east-1 To delete a vault, run this command. aws backup delete-backup-vault --backup-vault-name my-efs-vault --profile default --region us-east-1

January 6, 2021 · 1 min · ulysses

linux delete user

Here’s how to delete a Linux user. userdel username Delete user and the home directory. userdel -f username

January 6, 2021 · 1 min · ulysses

vintela troubleshooting

Vintela is a utility for allowing AD users to login to Linux. Here are some basic troubleshooting tips. #check version vastool -v # check status vastool status # start stop script /etc/init.d/vasd start/stop/restart # check user access vastool user checkaccess username # list users vastool list users # flush cache vastool flush # unjoin domain vastool unjoin -f -l # join domain vastool -u username@domain.com -w password join -f -c OU=Linux,OU=linux,OU=Servers,DC=domain.com,DC=net domain.com Important files. ...

January 6, 2021 · 1 min · ulysses