Be VERY CAREFUL with this. sudo dpkg -l ‘linux-*’ | sed ‘/^ii/!d;/'”$(uname -r | sed “s/\(.*\)-\([^0-9]\+\)/\1/”)”‘/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d’ | xargs sudo apt-get -y purge 😉 nJoy
Category: Uncategorized
PM2 set logs to compress and expire
Referring to the github README.md https://github.com/pm2-hive/pm2-logrotate pm2 install pm2-logrotate@2.6.0 pm2 set pm2-logrotate:compress true pm2 set pm2-logrotate:max_size 10M pm2 set pm2-logrotate:retain 7 pm2 conf { “pm2-logrotate”: { “max_size”: “10M”, “retain”: “7”, “compress”: “true”, “dateFormat”: “YYYY-MM-DD_HH-mm-ss”, “workerInterval”: “30”, “rotateInterval”: “0 0 * * *”, “rotateModule”: true }, “module-db”: { “pm2-logrotate”: { “uid”: null, “gid”: null } }…
Enable actual saving of coredump in node and other Linux based apps
ulimit -c unlimited nJoy 😉
Show all cronjobs for all users
This is a simple script to get all cronjbs for all users on a system for someone in $(cut -f1 -d: /etc/passwd); do echo $someone; crontab -u $someone -l ; done nJoy 😉
Dummy node script to respond 200 (or anything) to a call for testing purposes
This is as bare a node App as you can make but it comes in handy when you want a . dummy server just to return 200s and or a JSON object at super fast speeds on small systems: var express = require(‘express’); var app = express(); app.get(‘*’, function(req, res) { res.sendStatus(200); }); app.listen(‘3000’);…
Installing node on old version of Ubuntu 10.04
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash logoff and log on nvm ls-remote nvm install v7.9.0 npm -v node -v Caveat :  Lots of node stuff fails to compile and run on such an old version of linux be warned… Thats it you now have node and npm installed. nJoy 😉
send video from local device to a slave computer with ffmpeg
setup service listener on viewer machine : while : ; do ffplay -i tcp://192.168.xx.xx:1234?listen ; done send video to it : ffmpeg -re -i /dev/video1 -vcodec mpeg2video -f alsa -i hw:2,0 -ac 2 -s 1920×1080 -r 25 -strict -2 -f mpegts tcp://192.168.xx.xx:1234 where 192.168.xx.xx is the IP of the viewer where the ffplay is running….
starting a machine in Docker with ports
docker run -p 800:80 -p 2222:22 -p  4443:443  -it 68715929d32a  /bin/bash If ports do not work check : sysctl net.ipv4.ip_forward if  you get: net.ipv4.ip_forward = 0 then issue : sysctl -w net.ipv4.ip_forward=1 net.ipv4.ip_forward = 1if you get the error : docker: Error response from daemon: driver failed programming external connectivity on endpoint amazing_williams (44e256a6039741b20e4124800702d9794d69fb6be9da71ba25059de4dd527121):…
Docker enable internet and external routing
You could add the sysctl line to the system or in the /etc/init.d/
Adding timestamps to PM2 logs
pm2 start app.js –log-date-format ‘DD-MM HH:mm:ss.SSS’ nJoy 😉