define( 'DISALLOW_FILE_EDIT', true );
The post Quick tips using FIND , SSH, TAR , PS and GREP Commands appeared first on Managed Wordpress Hosting | Managed VPS Hosting | Stack Star.
]]>Over time, I’ve jotted down several quick useful notes regarding using various linux/unix commands. I’ve found them very useful when navigating and performing various tasks. I decided to share them with you, so hopefully you will find them a useful reference at the very least!
To find files within a time range and add up the total size of all those files :
find /opt/uploads -mtime -365 -printf "%sn"|awk '{sum+=$0}END{print sum}'
To watch a command’s progress :
watch -n1 'du -h -c --max-depth=1'
Transfer a file / folders, compress it midstrem over the network, uncompress the file on the recieving end:
ssh -l root 00.00.000.000 '(cd /opt/uploads/ && tar -czf - . -C /opt/uploads)' | tar -xzf -
Below will return any XYZ PID that is older than 10 hours.
ps -ef | grep XYZ | awk '{ print $7 ":" $2 }' | awk 'BEGIN { FS =":" }; {if ($1 > 10) print $4}'
Check web logs on www server for specific ip address access:
grep "ip_address" [a-h]*/logs/*access*4 <-- check a-h websites grep "ip_address" [A-Z,0-9]*/logs/*access*4 <-- check A-Z, 0-9 websites
Those are just a few of the useful commands that can be applied to many different functions. I particularly like sending files across the network and compressing them mid stream :)
The above kind of administration is made even easier when you employ ssh key based authentication -- your commands can be scripted to execute across many servers in one sitting (just be careful) ;)
The post Quick tips using FIND , SSH, TAR , PS and GREP Commands appeared first on Managed Wordpress Hosting | Managed VPS Hosting | Stack Star.
]]>