Monitor a running process on a ubuntu server

The use case I had for this was when I wanted to copy over a large data from one server to another and this was going to take a couple of hours.

So I just started the rcyncas a background process on the server and used the following command to monitor the process output from time to time.

sudo strace -e open $(ps -o lwp= -LC rsync | sed 's/^/-p/')

Enable and disable Xdebug quickly on OS X homebrew php 7.1

Xdebug is a powerful tool for debugging PHP code, but it can be a memory hog when it is continuously turned on. Xdebug can be quickly enabled and disabled by creating simple custom scripts.

Download these shell files on your Mac, make them executable and you are good to go!

curl -L -o /usr/local/bin/disable-xdebug
curl -L -o /usr/local/bin/enable-xdebug
chmod +x /usr/local/bin/*able-xdebug

Now run enable-xdebug on your terminal to enable Xdebug and disable-xdebug to disable it.

Shell script to restart MySQL automatically when it shuts down.

A dirty hack but essential at times, the MySQL server consumes higher memory if not configured correctly and due to this the MySQL service is terminated by the OS to save itself from crashing under high traffic.

A simple shell script can be used to restart the MySQL service when it is terminated.

Download this script using wget


Make the script executable

sudo chmod +x

Execute this script each minute with a crontab

sudo crontab -e
*/1 * * * * sh /path/to/script/