服务器nginx偶尔会被杀死,可能是系统资源不够了。
sudo systemctl edit nginx
then paste in:
[Service]
Restart=always
check if it works
sudo systemctl status nginx
sudo pkill -f nginx
sudo systemctl status nginx
sudo apt-get install mosquitto mosquitto-clients
sudo mosquitto_passwd -c /etc/mosquitto/passwd <mqtt_user> (set passwd here)
sudo vi /etc/mosquitto/conf.d/default.conf # new file with
allow_anonymous false # disable anonymous user
listener 1883 0.0.0.0 # open to all IP, open to localhost by default.
password_file /etc/mosquitto/passwd # make password work
sudo /etc/init.d/mosquitto restart
mosquitto_sub -h localhost -u netro -P netrohome -t 'test'
mosquitto_pub -h localhost -u netro -P netrohome -t 'test' -m 'hello'
The default max open file is 1024, which may not be enough for large MQTT service, increase it to 65535
# vi /etc/systemd/system.conf
DefaultLimitNOFILE=65536:524288
sudo systemctl daemon-reexec
sudo /etc/init.d/mosquitto restart
# cat /proc/<pid>/limits should be:
Max open files 65535 524288 files
# count the number of file opened by:
sudo ls /proc/<pid>/fd | wc -l
安装ubuntu,默认LVM,全盘安装。但是装完发现只有100G,另外的130多G去哪里了?
参见guide
扩展
lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
undo remote commits:
git reset --hard 'xxxxx'
git clean -f -d
git push -f
gio mount smb://<servername>/<sharename>
# enter password
# once the mount is created it will create a temporary path located at the following path, for example:
# /run/user/1000/gvfs/smb-share\:server\=host.domain.com\,share\=files/
ln -s /run/user/<userid>/gvfs/smb-share\:server\=<servername>\,share\=<sharename>/ ~/<mountpoint>
sudo -H gedit /etc/systemd/logind.conf
HandleLidSwitch=ignore
sudo service systemd-logind restart
# Still sleep after idle
sudoedit /etc/UPower/UPower.conf
Change IgnoreLid to IgnoreLid=true
service upower restart
# also in /etc/systemd/logind.conf
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
HandleHibernateKey=ignore
HandleSuspendKey=ignore
IdleAction=ignore
IdleActionSec=0
# Still sleep after idle
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
路由器NAT映射端口,尝试并成功
python3 -m http.server
.ssh/config
TCPKeepAlive yes
ServerAliveInterval 30
ssh -o TCPKeepAlive=yes user@some.host.com
ssh -o ServerAliveInterval=30 user@some.host.com
TCPKeepAlive: This uses the KEEPALIVE option of the TCP/IP protocol to keep a connection alive after a specified interval of inactivity. On most systems, this means 2 hours. So, with the TCPKeepAlive option passed to SSH, the SSH client will send an encrypted packet to the SSH server, keeping your TCP connection up and running.
ServerAliveInterval: This sets a timeout interval in seconds, which is specified by you, from which if no packets are sent from the SSH client to the SSH server, SSH will send an encrypted request to the server for a TCP response. To make that request every 30 seconds:
mongodump --db country --gzip --archive=country.archive
mongorestore --gzip --archive=country.archive
NOTE: The archive is mongo-specific format, can't be opened by other tools e.g. tar
sudo crontab -e
@hourly rm somefile