Keep the time and date of your Linux box always up to date


The attached file is a simple bash script, to correct the date and time of your linux box (binaries paths are relative to a Debian Etch).


  • ntpdate: apt-get install ntpdate
  • ntpd stopped: if you have a ntp daemon running you don't need this script
  • port 123 (UDP) opened
  • user permission: the user that run the script must have the permission to set up the clock

What the script does

Debian and MySql 5: where has 'debian-log-rotate.conf' file gone?


In a Debian standard installation of MySql 4, binary logs are purged automatically. The file /etc/mysql/debian-log-rotate.conf is needed to tell logrotate how many log files to keep.

Starting from MySql 5, purging of binary logs is done directly by MySql so there is no more need of debian-log-rotate.conf and the rotation is configured in the my.cnf file with the following entry:

expire_logs_days = 30 # WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!

Easy find and replace with perl


If you need an easy way to find and replace a string in one or more text files (php script, bash script, perl script or just text) using only a command, may be that the following is the easiest way:

find . -name '[PATTERN]' |xargs perl -pi -e 's/[NEEDLE]/[REPLACESTR]/g'

Example: if you are in the folder where you usually store you alert script, that send email on certain events, and you want to replace the previous email with the new one you can type

find . -name '*.php' |xargs perl -pi -e 's/oldemail@domain.tld/newemail@domain.tld/g'


Error: Argument list too long


Using linux shell commands such as cp, mv, rm you could encounter the following error message:

/bin/cp: Argument list too long.

Obviously you can modify system settings and increase the max number of files, but an easyer solution is using the find command.

Example: to remove a great number of temporary files in a folder, all with the '.dieg' extension , try this (or something similar!):

find ./ -name '*.dieg' -exec rm -r -v {} \;

BASH: bad interpreter: No such file or directory


If you are getting this error message from a linux shell

bad interpreter: No such file or directory

over and over again, may be a "path" variable setting mistake, that is the correct interpreter (e.g. bash) can't be found and you have to specify the full path. Else the script file has been witten on a win32 machine, so the "end of line" character is '\r\n' rather than '\n'.

If this last case, you can solve the problem editing the script file with "vim" and digiting:

:set fileformat=unix

and finally to save: