How to check dd progress?

Using dd I wanted to see the progress. Solution: add pv. Here it is:

sudo dd if=/path/to/file.iso | pv | sudo dd of=/dev/diskX bs=4m

Simulate cron environment

Sometimes scripts aren’t working in cron, but they’re working manually. To debug them it’s helpful to simulate their running under cron environment.

add this to cron and let it to run at least once

* * * * * env > ~/cron_env

run this command to simulate environment:

env - `cat ~/cron_env` /bin/sh

Don’t run script if it’s running

The script will start only in case if the same script is not running.

#!/bin/bash
if ps -ef | grep -v grep | grep "process name" ; then
    echo "process running"
    exit 0
else
    echo "process not running"
    exit 0
fi

Download git with key-based access

This is how to download git project with key-based access:

ssh-agent bash -c 'ssh-add <key file>; git clone git@bitbucket.org:<user>/<repo name>.git'

Enable 80 port in CentOS

If you did an Apache installation then you also need to enable 80 port in iptables:

iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT