Check These Out
Put this code in a bash script. The script expects the PDF file as its only parameter.
It will add a header to the PDF containing the page numbers and output it to a file with the suffix "-header.pdf"
Requires enscript, ps2pdf and pdftk.
Dave Korn gave me this one. It works because ksh allows variable names ( w/o the $name syntax ) used by sh and bash.
I wrote it to permit "single source" shell libraries; the current objective: every shell library may be sourced by either shell. see http://github.com/applemcg/backash
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
poor man's xml parser :)
Converts any number of seconds into days, hours, minutes and seconds.
sec2dhms() {
declare -i SS="$1"
D=$(( SS / 86400 ))
H=$(( SS % 86400 / 3600 ))
M=$(( SS % 3600 / 60 ))
S=$(( SS % 60 ))
[ "$D" -gt 0 ] && echo -n "${D}:"
[ "$H" -gt 0 ] && printf "%02g:" "$H"
printf "%02g:%02g\n" "$M" "$S"
}
It grabs the PID's top resource users with $(ps -eo pid,pmem,pcpu| sort -k 3 -r|grep -v PID|head -10)
The sort -k is sorting by the third field which would be CPU. Change this to 2 and it will sort accordingly.
The rest of the command is just using diff to display the output of 2 commands side-by-side (-y flag) I chose some good ones for ps.
pidstat comes with the sysstat package(sar, mpstat, iostat, pidstat) so if you don't have it, you should.
I might should take off the timestamp... :|
The coolest way I've found to backup a wordpress mysql database using encryption, and using local variables created directly from the wp-config.php file so that you don't have to type them- which would allow someone sniffing your terminal or viewing your shell history to see your info.
I use a variation of this for my servers that have hundreds of wordpress installs and databases by using a find command for the wp-config.php file and passing that through xargs to my function.