Welcome
My name is Ulysses. Sr. Cloud Engineer at Cardinal Health.
About This Website
This is my static site based on Hugo.
My name is Ulysses. Sr. Cloud Engineer at Cardinal Health.
This is my static site based on Hugo.
Here’s how to list GCP’s manual snapshots. projectIds.txt contains a list of projects. #!/bin/bash ts=$(date +%Y%m%d-%H%M%S) log="manual-snapshots-logs-$ts" >$log while read -r project; do snapshots=$(gcloud compute snapshots list \ --project $project \ --filter="sourceSnapshotSchedulePolicy!=''" \ --format="value(name)") for snapshot in $snapshots do printf "%-30s %-30s \n" "$project" "$snapshot" | tee -a $log done done > projectIds.txt Another option. #!/bin/bash ts=$(date +%Y%m%d-%H%M%S) log="manual-snapshots-logs-$ts" >$log while read -r project; do snapshots=$(gcloud compute snapshots list \ --project $project \ --filter="-sourceSnapshotSchedulePolicy:*" \ --format="value(name)") for snapshot in $snapshots do printf "%-30s %-30s \n" "$project" "$snapshot" | tee -a $log done done > projectIds.txt
Here’s how to list GCP Scheduled Snapshots older than 14 days. projectIds.txt contains a list of projects. #!/bin/bash ts=$(date +%Y%m%d-%H%M%S) old=$(date -v -14d +%Y-%m-%dT%H:%M:%S) log="scheduled-snapshots-logs-$ts" >$log while read -r project; do snapshots=$(gcloud compute snapshots list \ --project $project \ --format="value(name)" \ --filter="creationTimestamp
How to add Snapshot Schedules to disks in Terraform. Add this to your existing VM. resource "google_compute_disk_resource_policy_attachment" "hourly_attachment" { name = "hourly-snapshots" disk = google_compute_instance.test.name zone = "us-central1-c" } resource "google_compute_disk_resource_policy_attachment" "daily_attachment" { name = "daily-snapshots" disk = google_compute_instance.test.name zone = "us-central1-c" }
How to enable unbound logs. Add these line in /etc/unbound/unbound.conf. chroot: "" logfile: /var/log/unbound.log verbosity: 4 log-queries: yes Create the log file and set permissions. touch /var/log/unbound.log chown unbound:unbound /var/log/unbound.log Restart the unbound service. systemctl restart unbound Check status. systemctl status unbound Finally, check the logs. tail -f /var/log/unbound.log
If you want to run a script every 11 months, here’s the crontab entry. * * 1 */11 * /bin/bash /path/to/script.sh
Replace spaces with commas from one file and send the output to another file. tr -s '[:blank:]' ', ' output.txt It’s perfect for creating a comma delimited file for importing to Excel.
Here’s how to reduce a MP4 video using H.265 format. ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4 I was able to reduce a video file from 550MB to 26MB without much quality loss.
How to sort files in Bash. Display contents $ cat file.txt bbb aaa ccc kkk uuu ppp Sort $ sort file.txt aaa bbb ccc kkk ppp uuu Sort in place $ sort -o file.txt file.txt $ cat file.txt aaa bbb ccc kkk ppp uuu
This will display only lines 40-50 in a file called lines.txt. $ cat lines.txt | head -n 50 | tail -n 10 For lines 90-100. $ cat lines.txt | head -n 100 | tail -n 10 and so on.
Here’s how to view system memory on Linux. Default display is in kB cat /proc/meminfo MemTotal: 7492768 kB MemFree: 427368 kB MemAvailable: 5424768 kB Display in MB awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t MemTotal: 7317.16 MB MemFree: 404.527 MB MemAvailable: 5285.4 MB Output in GB awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t MemTotal: 7.14566 GB MemFree: 0.370392 GB MemAvailable: 5.13733 GB