Skip to content

Instantly share code, notes, and snippets.

@tankhuu
Last active October 4, 2017 11:27
Show Gist options
  • Save tankhuu/31cca2c28abdba9093c6c367c44e2f39 to your computer and use it in GitHub Desktop.
Save tankhuu/31cca2c28abdba9093c6c367c44e2f39 to your computer and use it in GitHub Desktop.
Ubuntu 16.04 - Utilities
# VARIABLES #
swapSize=4G
# EXECUTE #
# Check swap
sudo swapon -s
# Create swapfile
sudo fallocate -l $swapSize /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
# Format swap file system
sudo mkswap /swapfile
# Apply swap
sudo swapon /swapfile
# Check swap
sudo swapon -s
free -m
# Persit enabling swap on startup
echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
# Optimize swap performance
sudo sysctl vm.swappiness=10
echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf
sudo sysctl vm.vfs_cache_pressure=50
echo "vm.vfs_cache_pressure = 50" | sudo tee -a /etc/sysctl.conf
# AWS Ubuntu is very easy to be time drifted
# We have to fix it manually
# https://aws.amazon.com/premiumsupport/knowledge-center/system-clock-drift-ubuntu/
# https://www.digitalocean.com/community/tutorials/how-to-set-up-time-synchronization-on-ubuntu-16-04
sudo apt-get update
sudo apt-get install ntp -y
sudo service ntp status
# Enable on startup
sudo update-rc.d ntp enable
# Enable ntp sync
sudo timedatectl set-ntp yes
sudo timedatectl
# If check and still see that: NTP synchronized: no
# try to
#sudo timedatectl set-ntp no
#sudo timedatectl set-ntp yes
/var/log/logstash/logstash-plain-*.log {
daily
rotate 30
compress
#delaycompress
missingok
notifempty
nocreate
dateext
dateformat -es1
extension .log
}
/data/www/deploy/project-name/shared/app/logs/prod-*.log {
su www-data www-data
daily
rotate 30
compress
missingok
notifempty
nocreate
dateext
dateformat -web1
extension .log
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment