How to clear memory cache on Linux Mint

I have system cache used a lot of memory after a long time of work with system so I looked for something what might clear the cache.

So these are scripts (available in 2.6.16 Linux core or newer):

  • Clears pagecache
  • sync
    echo 1 > /proc/sys/vm/drop_caches
    
  • Clears dentrie and inode кэши:
  • sync
    echo 2 > /proc/sys/vm/drop_caches
    
  • Clears pagecache, dentrie and inode кэши:
  • sync
    echo 3 > /proc/sys/vm/drop_caches
    

I’m using the last one.

Easy way to debug PHP script

If you can’t catch error in PHP script but something doesn’t work – add this to the beginning of your script:

ini_set('display_errors',1);
error_reporting(E_ALL);

this will allow you to see all errors.

Script for ssh port forwarding

Day to day I need to use ssh port forwarding and connect securely to my work servers. So I decided to create some simple bash script which will allow me to forward port via ssh and to kill previous tunnel if it freezed.

Script source:


#!/bin/bash
# irc.sh
kill -9 `ps -aef | grep -i 'ssh -f -N -L 1234:127.0.0.1:1234 user@hostname.com' | grep -v grep | awk '{print $2}'`
ssh -f -N -L 1234:127.0.0.1:1234 user@hostname.com

Continue reading