Install and configure lsyncd on centos

Introduction :- Lsyncd watches a local directory trees event monitor interface (inotify or fsevents). It aggregates and combines events for a few seconds and then spawns one (or more) process(es) to synchronize the changes. By default this is rsync. Lsyncd is thus a light-weight live mirror solution that is comparatively easy to install not requiring

How to install Gearman PHP extension

Gearman PHP Extension While installing Gearman PHP extension I have used my custom path to use PHP config from. If we have custom installation of PHP we need to provide –with-php-config option while configure. We can find available option to give while configuring can be found by -help option passed with ./configure # ./configure –help

Bash phpize command not found

[root@localhost gearman-1.0.2]# phpize bash: phpize: command not found This error comes as “phpize” command is not available on my system To fix this, install php-devel package. (Eg: CentOS on my box) [root@localhost gearman-1.0.2]# yum install php-devel

20 Useful GREP Commands

20 Useful GREP Commands grep -V Show the version of Grep command like “grep (GNU grep) 2.14” grep "search string" file_name Search for the given string. grep "search string" file_name_* Search given string in multiple files. grep -i "search string" file_name Ignore case search. grep -w "This is a test" file_name Full world search. grep

To Find if a record exists or not in MySql

To Find if a record exists or not: Normally we use : SELECT COUNT(*) FROM anj_table WHERE fileldName = ‘anj_field’ Instead use sub-query SELECT EXISTS (SELECT 1 FROM `anj_table` WHERE fieldName = ‘anj-value’ ) It executes faster than SELECT COUNT(*) to get if a particular row exists or not. Reason being sub-query stop executing when

Common Linux commands

Archive.tar Create Archive tar cvf archive.tar dir_name/ Creating archive.tar Extract Files tar xvf archive.tar Extracting all files from archive.tar tar xvf archive.tar /path/to/file Extract a single file from archive.tar tar xvf archive.tar /path/to/dir/ Extract a single directory from archive.tar tar xvf archive.tar --wildcards '*.php' Extract group of files from archive.tar using –wildcards View Files tar

How to join variables in a bash script

To join/concatenate two variables in bash-script use following: 1) “${var1}_${var2}” # here we have joined var1 and var2 separated by ‘_’ 2) basePath=”/home/anj/” # base part. fileName=”myfile.txt” # fitename fileName=”${basePath}/${fileName}” # separated by / It is quite simple just place each variable adjacent to each other. ${basePath}/${fileName}” avoid variable substitution issues (if any).

How to write php array in a file

Sometimes we want to store php array in file for debugging or examination purpose. One way for this is to capture all the values (including array ) in buffer and later print on a file: For example: ob_start(); // Start buffering print_r($arrValue); // Print the value of array. We can also use var_dump just as