Skip to content

Instantly share code, notes, and snippets.

@majedbojan
Last active July 23, 2020 08:22
Show Gist options
  • Save majedbojan/182d2368069c103aba1da5e96cab9ec7 to your computer and use it in GitHub Desktop.
Save majedbojan/182d2368069c103aba1da5e96cab9ec7 to your computer and use it in GitHub Desktop.
Daily Shell Commands
# Rotate logs
1) vim or nano /etc/logrotate.conf
2) Add these lines to the bottom of the file
/home/deploy/APPNAME/current/log/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
copytruncate
}
You’ll need to change the first line to match the location where your Rails app is deployed
3) run logrotate manually `sudo /usr/sbin/logrotate -f /etc/logrotate.conf`
4) run the above command again to make sure the delaycompress option is working and to actually compress the log.
# Redis
# run redis in backfound
redis-server --daemonize yes
# Check redis server started or not
ps aux | grep redis-server
# Remove all the keys of all the existing database
redis-cli FLUSHALL
# Redis logs
sudo tail /var/log/redis/redis-server.log -n 100
# sidekiq
# Restart sidekiq
bundle exec sidekiq -d -P tmp/sidekiq.pid -L log/sidekiq.log
# Puma
cap dev puma:start # -> start puma
cap dev puma:status # -> check the status
cap dev puma:stop # -> stop puma
cap dev puma:restart # -> restart puma
#If the puma still not started run it from the server
bundle exec puma -C /var/PATH/TO/PROJECT_FILE_NAME/shared/puma.rb
# Clear server logs
RAILS_ENV=production ~/.rvm/bin/rvm 2.6.2@GEMSET_NAME do bundle exec rake log:clear
# Kill local server procces
kill -9 $(lsof -i tcp:3000 -t)
# Change Time zone of local or server
sudo dpkg-reconfigure tzdata
# Display the system's time
timedatectl
# Nginx
# Make sure nginx configurations file has no syntex error
sudo service nginx configtest
# Restart, Relod nginx service
sudo service nginx reload
sudo service nginx restart
# nginx logs
/var/PATH/TO/PROJECT_FILE_NAME/current/log tail -f -n 100 nginx.error.log
# pg
# Grant access to postgres user and rais to system files
chown -R postgres:postgres /var
sudo chown -R postgres:postgres /var/lib/postgresql/
chmod u+x bin/rails
# Check what is the cluster you are running
pg_lsclusters
#restart pg service
sudo service postgresql start
# Checking File owner
ls -la /usr/local/lib/node_modules
# Finding logedin user
- id -un
- whoami
- echo $USER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment