How to convert MP3 to OGG audio format.
ffmpeg -i in.mp3 -ar 48000 -vn -c:a libvorbis out.ogg |
If you have sample rate errors, use -vn.
cloud engineer
How to convert MP3 to OGG audio format.
ffmpeg -i in.mp3 -ar 48000 -vn -c:a libvorbis out.ogg |
ffmpeg -i in.mp3 -ar 48000 -vn -c:a libvorbis out.ogg
If you have sample rate errors, use -vn.
Here’s another way to create a firewall in GCP using network tag as targets.
gcloud compute firewall-rules create "firewall-name" \ --description="egress rule to allow port 8000 to destination" \ --priority "1000" \ --direction EGRESS \ --action allow \ --network "your-network" \ --target-tags="your-network-tag" \ --destination-ranges="10.0.0.1/32" \ --rules tcp:8000 |
gcloud compute firewall-rules create "firewall-name" \ --description="egress rule to allow port 8000 to destination" \ --priority "1000" \ --direction EGRESS \ --action allow \ --network "your-network" \ --target-tags="your-network-tag" \ --destination-ranges="10.0.0.1/32" \ --rules tcp:8000
When you stand up an AWS instance, it’s only accessible via SSH key using the default user, typically ec2-user.
Add password to ec2-user, then enable password authentication to ‘yes’ in SSH.
# Add password to ec2-user sudo passwd ec2-user # edit ssh config vim /etc/ssh/sshd_config # enable password authentication PasswordAuthentication yes # save file and exit |
# Add password to ec2-user sudo passwd ec2-user # edit ssh config vim /etc/ssh/sshd_config # enable password authentication PasswordAuthentication yes # save file and exit
Restart SSH service.
systemctl restart sshd.service |
systemctl restart sshd.service
This is a Bash script to restart a service.
#!/bin/bash SERVICE=google_osconfig_agent AGENT=google-osconfig-agent if (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) > 0 )) then echo "$AGENT service running, everything is fine" else echo "$AGENT is not running" echo "Restarting service" systemctl start $AGENT sleep 5s if (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) > 0 )) then sleep 2s echo "$AGENT service is now running" fi fi |
#!/bin/bash SERVICE=google_osconfig_agent AGENT=google-osconfig-agent if (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) > 0 )) then echo "$AGENT service running, everything is fine" else echo "$AGENT is not running" echo "Restarting service" systemctl start $AGENT sleep 5s if (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) > 0 )) then sleep 2s echo "$AGENT service is now running" fi fi
This is a Powershell script to restart a service if it’s down.
$ServiceName = 'GCEAgent' $arrService = Get-Service -Name $ServiceName if ($arrService.Status -ne 'Running') { Start-Service $ServiceName write-host $arrService.status write-host 'Service starting' Start-Sleep -seconds 60 $arrService.Refresh() if ($arrService.Status -eq 'Running') { Write-Host 'GCE Agent Service is now Running' } } else { Write-Host 'GCE Agent Service is Running' } |
$ServiceName = 'GCEAgent' $arrService = Get-Service -Name $ServiceName if ($arrService.Status -ne 'Running') { Start-Service $ServiceName write-host $arrService.status write-host 'Service starting' Start-Sleep -seconds 60 $arrService.Refresh() if ($arrService.Status -eq 'Running') { Write-Host 'GCE Agent Service is now Running' } } else { Write-Host 'GCE Agent Service is Running' }
Here’s how to describe snapshots using query with tags.
aws ec2 describe-snapshots \ --owner-ids xxxxxxxxxxx \ --profile default \ --region us-east-2 \ --output text \ --query "Snapshots[*].[SnapshotId,Tags[?Key=='Name'].Value[] | [0]]" |
aws ec2 describe-snapshots \ --owner-ids xxxxxxxxxxx \ --profile default \ --region us-east-2 \ --output text \ --query "Snapshots[*].[SnapshotId,Tags[?Key=='Name'].Value[] | [0]]"
Result.
snap-xxxxxxxxxxxxxxxxx Server1 snap-xxxxxxxxxxxxxxxxx Server2 |
snap-xxxxxxxxxxxxxxxxx Server1 snap-xxxxxxxxxxxxxxxxx Server2
Here are some missing PHP modules on my WordPress install.
apt install php-gd php-dom php-mbstring php-imagick php-zip |
apt install php-gd php-dom php-mbstring php-imagick php-zip
Reboot Apache after the install.
systemctl restart apache2 |
systemctl restart apache2
If you don’t have it installed.
yum install screen apt install screen |
yum install screen apt install screen
Before you run a process, run screen, and detach.
screen # run the command ping yahoo.com # ctrl-a and ctrl-d to detach |
screen # run the command ping yahoo.com # ctrl-a and ctrl-d to detach
To reattach, get a list of screen sessions, and attach to it.
screen -ls # result is somewhat similar to below 4452.hostname # attach to it screen -dr 4452.hostname |
screen -ls # result is somewhat similar to below 4452.hostname # attach to it screen -dr 4452.hostname
To stop, just type exit from the screen terminal.