Categories
#DEV

Run Tasks/Jobs in the Background while closing the SSH Session

We usually run imports and exports for our email marketing software using PHP-CLI (Command-line Interface). The problem comes when we want to work on something else. Instead of opening multiple terminal sessions, we use this little application called Screen. This little application is quite handy when it comes to keeping those sessions alive by running tasks/jobs in the background. Screen is a console application that allows you to have multiple terminal sessions within a single window.

If you don’t have it installed, you can install it by using the following command:

sudo apt-get update
sudo apt-get install screen

To use:

screen -dmSL [session name] [commands]

d – starts a session and immediately detaches from it
m – forces the creation of a new session
S – lets you give the session a friendly name
L – turns on logging to ~/screenlog.0

To detach and keep the processes running:

Ctrl + A + D

To resume the session:

Screen -x "session-name"
Categories
#DEV

Linux/Unix Commands for Unzip GZ Files

GZ is no doubt one of the best choices for database compression. We use it quite often when importing and exporting files. In fact, we recently used it for migrating our MySQL databases to Amazon RDS.

To extract a GZ file, use Gunzip command:

gunzip file.gz

If that had no success, try this:

gzip -d file.gz

To check if new extracted file exists, enter the following:

ls -l