Skip to content

Instantly share code, notes, and snippets.

@dungmanh88
dungmanh88 / Find log cronjob on systemd
Created September 26, 2016 03:05
Find log cronjob on systemd
### Get crond service name
systemctl list-units --all | grep -i cron
### View log of crond service on systemd
journalctl -u cron.service | less
or
systemcl status cron.service
@dungmanh88
dungmanh88 / Find cron init script on systemd
Created September 26, 2016 03:08
Find cron init script on systemd
systemctl cat cron.service
or
cat /etc/init.d/cron
@dungmanh88
dungmanh88 / Compare two files
Created September 26, 2016 03:08
Compare two files
diff <file1> <file2>
or
sum1=`md5sum <file1> | cut -d " " -f 1`
sum2=`md5sum <file2> | cut -d " " -f 1`
[ "$sum1" == "$sum2" ] && echo "equal" || echo "not equal"
@dungmanh88
dungmanh88 / Prevent cron service start automatically or manually on systemd
Created September 26, 2016 03:12
Prevent cron service start automatically or manually on systemd
systemctl mask cron.service
systemctl list-unit-files | grep cron.service
## For unmask
systemctl unmask cron.service
@dungmanh88
dungmanh88 / Open port firewall for ntp service and dns service
Created September 26, 2016 06:11
Open port firewall for ntp service and dns service
/sbin/iptables -A INPUT -i $my_interface -s 0/0 -d $my_local_ip -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A OUTPUT -o $my_interface -s $my_local_ip -p udp -m multiport --dport 53,123 -j ACCEPT
@dungmanh88
dungmanh88 / Change ntp server using by ntp.service
Created September 26, 2016 06:15
Change ntp server using by ntp.service
# Get IP server in pool that my ntp service is getting connection
ntpq -pn
Change that list:
vi /etc/ntp.conf
pool 0.ubuntu.pool.ntp.org iburst
pool 1.ubuntu.pool.ntp.org iburst
pool 2.ubuntu.pool.ntp.org iburst
pool 3.ubuntu.pool.ntp.org iburst
@dungmanh88
dungmanh88 / Synchronize time immidiately
Created September 26, 2016 06:26
Synchronize time immidiately
systemctl stop ntp.service
# Synchronize time with server in pool in /etc/ntp.conf
ntpd -gq
systemctl start ntp.service
# View all servers
ntpq -pn
@dungmanh88
dungmanh88 / 1 - Debug mysqld server
Last active November 15, 2016 07:35
Debug mysqld - mariadb galera server
mysqladmin status
service mysql status
service mysqld status
ps -ef | grep mysqld | grep -v grep
mysql -uroot -p -A -e"SHOW VARIABLES;" > MySQLCurrentSettings.txt
tail -f /var/log/mysqld/mysql_error.log
tail -f /var/log/mysqld/mysql_slow.log
pt-summary
pt-mysql-summary --user=root --ask-pass
pt-variable-advisor localhost --user=root --ask-pass
@dungmanh88
dungmanh88 / Open port for galera node
Last active October 1, 2016 15:26
Open port for galera node
port 3306 for mysqld
port 4567 for replication traffic
port 4444 for joiner get SST from donor
@dungmanh88
dungmanh88 / Use mysqltuner.pl
Created September 26, 2016 18:03
Use mysqltuner.pl
wget http://mysqltuner.pl/ -O mysqltuner.pl
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv
chmod u+x mysqltuner.pl
perl mysqltuner.pl