Jump to Navigation

045 - How to use clearstatcache(), stat()

When you use stat(), istat(), or any of the other functions listed in the affected functions list ,PHP caches the information those functions return in order to provide faster performance. However, in certain cases, you may want to clear the cached information. You can use the clearstatcache() function to clear the information that PHP caches about a file.


044 - touch command

1. Create an empty file

$ touch myfile

2. touch command changes two timestamps associated with a file

$ touch -d "Dec 18 2007" myfile

$ stat myfile


043 - To optimize a slow MySQL query

  1. Find out whether the application is retrieving more data than you need. That usually means it’s accessing too many rows, but it might also be accessing too many columns.
  2. Find out whether the MySQL server is analyzing more rows than it needs.
    (Use EXPLAIN’s output to understand.)
  3. Chopping up a query. Running it in smaller chunks that affect fewer rows each time.

042 - How to get last lines in a million lines file.


$i=0 ;
$lines=20 ;
$file = 'file_name.txt';
$fp = fopen($file,"r") ;
fseek($fp,0,SEEK_END) ;
$a = ftell($fp) ;
while($i <= $lines){
if(fgetc($fp) == "\n"){
echo (fgets($fp)) . "<br />";
$i++ ;
fseek($fp,$a) ;
$a-- ;

041 - How to install MySQL on ubuntu/debian

Before installation, make sure your package management tools are up-to-date. Also make sure you install all
the latest software available.

# sudo apt-get update

# sudo apt-get dist-upgrade

After a few minutes (depending on the state of your system), you’re ready to install MySQL on ubuntu.


040 - PEAR

PEAR is a framework and distribution system for reusable PHP components and presently offers more than 400
packages categorized under 37 different topics.

Installing PEAR on Linux:

lynx -source http://go-pear.org | php

Installing PEAR on Windows:


%>pear list   (Viewing the packages installed on your machine.)

%>pear info Console_Getopt  (Learning more about an installed PEAR package)

039 - crontab

The crontab command, like at, schedules jobs for specific times. However, crontab is for recurring jobs,
such as "Run this command at midnight on the second Tuesday of each month." To make this work,
you edit and save a file (crontab). The superuser can add the option -u username to work with other's
crontab files. Crontab files contain one job per line.

$ crontab -e  (Edit your crontab file in your default editor)

$ crontab -l   (Print your crontab file on standard output)

$ crontab -r   (Delete your crontab file)


038 - Package Management

The Red Hat package Manager (RPM)

The Red Hat Package Manager (RPM) is a freely available packaging system for software distribution and
installation. In addition to Red Hat Enterprise Linux and Fedora Core distributions, both SUSE and Mandrake
are among the Linux distributions that use RPM.

Yellowdog Updater Modified (YUM)


037 - XFS Filesystem for EC2

The XFS filesystem seems to be the preferred choice for the persistent storage for EC2, due to its ability
to freeze the filesystem during a snapshot operation, and you'll need the following to be installed
to take advantage of that:

Example (Fedora, CentOS):


036 - EC2 user selectable Kernels

Amazon EC2 allows developers to use kernels other than the default Amazon EC2 kernels with their instances.
An Amazon Kernel Image(AKI) is similar to an Amazon Machine Image(AMI). The latter is prefixed with "ami-"
while the former is prefixed with "aki-". In addition, Amazon EC2 supports Amazon RAM disk images(ARI)
which might be required by kernels and are prefixed with "ari-".
Anyone can use alternative kernels or RAM disks with their AMIs, but the ability to create and publish
kernels and ramdisks is restricted to Amazon EC2 and selected vendors.



Subscribe to LAMP, Database and Cloud Technical Information RSS

Main menu 2

by Dr. Radut