Everything for the Ubuntu Server Administrator

User Tools

Site Tools


Server Administration

Server Applications

At the Command Line


Copyright 2013 Applied Conscious Technologies, LLC

Terms of Agreement


submit to reddit


At the Command Line

Time and Date

Handy Timezone Conversion Web Page


Display a Calendar

cal -3

Display a Calendar for a Particular Month and Year

cal 9 1752

Today's Date in a Full-year Calendar

cal -y | tr '\n' '|' | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/./#/g') /$(date +%m | sed s/^0//)" | tr '|' '\n'

What Date is it this Friday

date -d fri

What Day does Christmas Fall On

date --date='25 Dec' +%A

Date/Time Conversion

Convert Seconds Since the Epoch (1970-01-01 UTC) to Date

date --date='@2147483647'

Use the Date Command to do Timezone Conversion

date -d 'tomorrow 19:00 UTC-08'

Email a Reminder

 echo "mail -s 'get the train' > /dev/null" | at 17:45

Time a Command

time command

Start a timer

time cat

Enter control-D to stop.

Date/Time and Scripts

Run a Script at a Certain Time

note: /usr/share/doc/at/timespec has the specs for time specification. The time is entered in GNU date format.

sudo at -f /home/andrew/bin/ 16:00 Friday

To help deal with timezone conversion:

Exit a Script Unless it's the Last Day of the Month

[ $(date -d "tomorrow" +%d) = "01" ] || exit


Coordinated Universal Time

World-connected servers commonly run on UTC, so it is necessary to deal with the difference between wherever you are and UTC.

Get Current UTC Time

TZ=':UTC' && date

Get Current Time in Los Angeles

TZ=America/Los_Angeles && date

Calculate Time from a Specified Timezone

TZ=':America/Los_Angeles' && date -d "+7 hours"

another example:

TZ=':America/Los_Angeles' && date -d "+ 2weeks +7 hours"


Show the Server's Timezone

cat /etc/timezone
perl -E 'use POSIX; print strftime("%Z", localtime()), "\n";'

View Available Timezones

tzselect is a menu driven program that will allow you to find a timezone. It will not allow the server's timezone to be changed, but will show you the TZ value that you can use to do so with “sudo dpkg-reconfigure tzdata”.


tzselect man page:

Change the Server's Timezone

sudo dpkg-reconfigure tzdata

time_and_date.txt · Last modified: 2015/05/31 21:20 (external edit)