This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# generate a number of files with random sizes in a range | |
min=1 # min size (MB) | |
max=10 # max size (MB) | |
nofiles=20 # number of files | |
for i in `eval echo {1..$nofiles}` | |
do | |
dd bs=1M count=$(($RANDOM%max + $min)) if=/dev/urandom of=./files/file$i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# www.fduran.com | |
# exclude a process from being killed by oom killer | |
echo -17 > /proc/$PID/oom_adj | |
# The possible values of oom_adj range from -17 to +15. The higher the score, more likely the associated process is to be killed by OOM-killer: https://lwn.net/Articles/317814/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# www.fduran.com | |
# what is this process? - mini forensics on unknown running process | |
ls -l /proc/$pid/exe | |
dpkg -S /path/to/process_binary | |
strings /path/to/process_binary | |
hexdump -C /path/to/process_binary | |
netstat -tapn|grep tang | |
lsof $pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# www.fduran.com | |
# set up Celery with Django (dev queuing) | |
(source activate) | |
# install (kombu is included) | |
pip install celery | |
pip install django-celery | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Postfix mail review | |
# look at logs | |
tail /var/log/mail.log | |
tail /var/log/mail.err | |
# view queue | |
mailq | |
# delete deferred messages in queue | |
postsuper -d ALL deferred |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# www.fduran.com | |
# Run script detached from an SSH terminal | |
nohup script.sh </dev/null & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# www.fduran.com | |
# check ssl connection | |
echo '' |openssl s_client -ssl3 -connect google.com:443 -CApath /usr/share/ssl-cert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# www.fduran.com | |
# sync (copy) local to remote server directory | |
# take out dry-run after test | |
rsync --dry-run -azvrh -e 'ssh -p 2022' --exclude 'donotcopy' /var/www/ [email protected]:/var/www/ | |
# options: | |
a: archive, preserve metadata | |
z: compression | |
v: verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# www.fduran.com | |
# test cronjobs | |
# cron running? | |
pgrep cron | |
service cron status | |
# or crond for redhat, other distros above | |
# add line in crontab: | |
*/1 * * * * root /bin/date >> /tmp/cronlog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# www.fduran.com | |
# renice many processes with the same name | |
for i in `pgrep processname`; do renice 20 -p $i; done |