martes, 2 de diciembre de 2008

Esa navaja suiza antes conocida como "date"

GNU date is one of the many common Linux programs in GNU Coreutils package. Here are some of the examples of performing date time arithmetic with GNU date command, using -d or --date option switch:
date -d "last month" +%m
Return as last month in numeric format
date -d "2 month ago" +%b
Return as last month in abbreviated month name
date -d "-2 month" +%B
Return as last month in full month name
date -d "-1 hours" +%H
Returns previous hour in 24-hours format (00-23)
date -d "tomorrow"
Return the date and time of tomorrow
date -d "yesterday" +"%d %B %y"
Return the date of yesterday in dd MMM yy
date -d "last week" +%a
Return last week in abbreviated weekday name
date -d "$(date +%Y-%m-15) -1 month" +'Last month was %B!'
To avoid getting result of “July” when executing date -d "-1 month" +%B on 31 July 2006, because “2006-07-31 -1 month” might evaluate to 2006-07-01, because 2006-06-31 is an invalid date!
date -d "1970-01-01 00:00:01 UTC" +%s
Return the Unix Epoch time (the total seconds elapse since midnight of 1970-01-01), which is 1 secs in this case.
date -d "1970-01-01 1234567890 sec" +"%F %T %z"
Return the literal date format of the given Unix Epoch time.

lunes, 1 de diciembre de 2008

Cambiar la hora el sistemas Linux

Leo en Bulma, despues de buscar en Google como cambiar la hora en Linux:

Para cambiar la hora del sistema usaremos el comando date, pero hemos de tener en cuenta que al reinicializar el ordenador, éste cogerá la hora de la BIOS y nos volverá a colocar la hora anterior, para evitar esto cambiaremos también la hora de la BIOS con el comando hwclock como se detalla a continuación:

Suponemos que queremos colocar la fecha: 25-Feb-2000 y la hora 16:25.
Esto lo haremos como root:

# date --set "2000-02-25 16:25"
Fri Feb 25 16:25:00 CET 2000

Ahora realizaremos el mismo cambio para actualizar la fecha en la BIOS.
# hwclock --set --date="2000-02-25 16:25"

Para comprobarlo tecleamos:
# hwclock
Fri Feb 25 16:25:06 2000 -0.010586 seconds