Reading from standard input and writing to standard output or standard error using PHP

One of the most common command line tricks in Linux is to chain multiple commands using the pipe symbol i.e. you feed the output of one command as the input of another. This is called standard input and standard output redirection. PHP is usually used to program for the web but it can also be used as a shell scripting language to automate tasks and like any good shell scripting language it is possible to read from standard input and write to standard output using PHP.

Continue reading

Log rotation in CentOS Linux

CentOSLots of daemons running in CentOS Linux create their own log files. These log files contain helpful messages pertaining to the operation of those daemons. For example error messages that help in diagnosing problems with the system. Over time these log files have to be rotated so that they are easier to manage. Log rotation is the process of splitting large log files and archiving old log files for future reference. In CentOS a program called logrotate is responsible for rotating log files. In this post I look at how to customize the operation of logrotate.

Continue reading