Unix Date Format Specifiers
Last Updated on Tuesday, 05 July 2011
Source: Wikipedia: Date (Unix)
| Specifier | Description | Values/Example |
|---|---|---|
| Day | ||
| %a | weekday, abbreviated | Mon |
| %A | weekday, full | Monday |
| %d | day of the month (dd), zero padded | 04 |
| %e | day of the month (dd) | 4 |
| %j | day of year, zero padded | 001-366 |
| %u | day of week starting with Monday (1), i.e. mtwtfss | 1 |
| %w | day of week starting with Sunday (0), i.e. smtwtfs | 1 |
| Week | ||
| %U | week number Sunday as first day of week | 01–53 |
| %W | week number Monday as first day of week | 01–53 |
| %V | week of the year | 01–53 |
| Month | ||
| %m | mm month | 07 |
| %h | Mon | Jul |
| %b | Mon, locale's abbreviated | Jul |
| %B | locale's full month, variable length | July |
| Year | ||
| %y | yy two digit year | 00–99 |
| %Y | ccyy year | 2011 |
| %g | 2-digit year corresponding to the %V week number | |
| %G | 4-digit year corresponding to the %V week number | |
| Century | ||
| %C | cc century | 00–99 |
| Date | ||
| %D | mm/dd/yy | 07/4/11 |
| %x | locale's date representation (mm/dd/yy) | 07/4/2011 |
| %F | %Y-%m-%d | 2011-07-4 |
| Hours | ||
| %l (Lowercase L) | hour (12 hour clock) | 1 |
| %I (Uppercase I) | hour (12 hour clock) zero padded | 01 |
| %k | hour (24 hour clock) | 13 |
| %H | hour (24 hour clock) zero padded | 13 |
| %p | locale's upper case AM or PM (blank in many locales) | PM |
| %P | locale's lower case am or pm | pm |
| Minutes | ||
| %M | MM minutes | 20 |
| Seconds | ||
| %s | seconds since 00:00:00 1970-01-01 UTC (Unix epoch) | 1309785651 |
| %S | SS second | 00–60 (The 60 is necessary to accommodate a leap second) |
| %N | nanoseconds | 000000000–999999999 |
| Time | ||
| %r | hours, minutes, seconds (12-hour clock) | 01:20:51 PM |
| %R | hours, minutes (24 hour clock) | hh:mm e.g. 13:20 |
| %T | hours, minutes, seconds (24-hour clock) | 13:20:51 |
| %X | locale's time representation (%H:%M:%S) | |
| Date and Time | ||
| %c | locale's date and time | Sat Nov 04 12:02:33 EST 1989 |
| Time zone | ||
| %z | -zzzz RFC-822 style numeric timezone | -0500 |
| %Z | time zone (e.g., EDT) nothing if no time zone is determinable | EST |
List all cron jobs for all users
Last Updated on Wednesday, 04 May 2011
- #!/bin/bash
- # System-wide crontab file and cron job directory. Change these for your system.
- CRONTAB='/etc/crontab'
- CRONDIR='/etc/cron.d'
- # Single tab character. Annoyingly necessary.
- tab=$(echo -en "\t")
- # Given a stream of crontab lines, exclude non-cron job lines, replace
- # whitespace characters with a single space, and remove any spaces from the
- # beginning of each line.
- function clean_cron_lines() {
- while read line ; do
- echo "${line}" |
- egrep --invert-match '^($|s*#|s*[[:alnum:]_]+=)' |
- sed --regexp-extended "s/\s+/ /g" |
- sed --regexp-extended "s/^ //"
- done;
- }
- # Given a stream of cleaned crontab lines, echo any that don't include the
- # run-parts command, and for those that do, show each job file in the run-parts
- # directory as if it were scheduled explicitly.
- function lookup_run_parts() {
- while read line ; do
- match=$(echo "${line}" | egrep -o 'run-parts (-{1,2}S+ )*S+')
- if [[ -z "${match}" ]] ; then
- echo "${line}"
- else
- cron_fields=$(echo "${line}" | cut -f1-6 -d' ')
- cron_job_dir=$(echo "${match}" | awk '{print }')
- if [[ -d "${cron_job_dir}" ]] ; then
- for cron_job_file in "${cron_job_dir}"/* ; do # */
- [[ -f "${cron_job_file}" ]] && echo "${cron_fields} ${cron_job_file}"
- done
- fi
- fi
- done;
- }
- # Temporary file for crontab lines.
- temp=$(mktemp) || exit 1
- # Add all of the jobs from the system-wide crontab file.
- cat "${CRONTAB}" | clean_cron_lines | lookup_run_parts >"${temp}"
- # Add all of the jobs from the system-wide cron directory.
- cat "${CRONDIR}"/* | clean_cron_lines >>"${temp}" # */
- # Add each user's crontab (if it exists). Insert the user's name between the
- # five time fields and the command.
- while read user ; do
- crontab -l -u "${user}" 2>/dev/null |
- clean_cron_lines |
- sed --regexp-extended "s/^((\S+ +){5})(.+)$/\1${user} \3/" >>"${temp}"
- done < <(cut --fields=1 --delimiter=: /etc/passwd)
- # Output the collected crontab lines. Replace the single spaces between the
- # fields with tab characters, sort the lines by hour and minute, insert the
- # header line, and format the results as a table.
- cat "${temp}" |
- sed --regexp-extended "s/^(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(.*)$/\1\t\2\t\3\t\4\t\5\t\6\t\7/" |
- sort --numeric-sort --field-separator="${tab}" --key=2,1 |
- sed "1i\mi\th\td\tm\tw\tuser\tcommand" |
- column -s"${tab}" -t
- rm --force "${temp}"
Changing the appearance of PUTTY
Last Updated on Wednesday, 08 September 2010
I've added this article because I didn't know before and now I do... Hopefully I won't forget but may do so I'll be able to look here and this should help.
How to run a .RUN file
Last Updated on Wednesday, 08 September 2010
I've been told of two ways of running a downloaded .RUN file.
Note: Bear in mind that the following is all case-sensitive.
Through the terminal server
- Download the .RUN file to your desktop
- Open a terminal by going to Application > Accessories > Terminal
- Type 'CD Desktop' to go to your desktop folder
- Type 'LS' just to check the .RUN file is in this one
- Type 'sudo sh nameoffile.run'
Through the Gnome GUI
- Right-click on the file you downloaded
- Select 'Properties'
- Select the 'Permissions' tab
- Tick the 'Execute' checkbox
Conclusion
The solution using the terminal worked for me but the second one using Gnome didn't.
Ubuntu as a media server
Last Updated on Wednesday, 08 September 2010
- 1. If someone wants to use Ubuntu as a home media pc connected to a
- tv, there is the problem of overscan; consumer tv's crop off the
- border around the image. How does Ubuntu intend to officially solve
- this? Right now LinuxMCE has it's own method for doing this so the
- LMCE UI is never cropped off, but when the user switches back to
- Ubuntu's gnome desktop, the top nav bar is cut off if he's using a
- normal tv and not a pc monitor. I'd like to have 1 screen adjustment
- tool that correctly adjusts both the lmce desktop and the main ubuntu
- desktop, so even when using the Ubuntu desktop on a TV, the top nav
- isn't cropped. Any ideas?

