From BLUGWiki
Jump to: navigation, search


Cron and At

cron and at are scheduling tools which allow you to perform commands on a schedule or on a single-time basis, respectively.

some evil distributions might not have cron by default even though it is included in POSIX.

to check to see if cron is installed on your system, run

ps -ef | grep cron 

the above command shows a list of processes running on the system with the string "cron"

the command crontab -e allows you to edit your crontab in your editor of choice.

MAILTO is a setting in crontab that allows you to specify an email address to which cron will notify you of any failed jobs. brown will probably filter your mail so that this won't work.

to schedule a cron job, include a line with the following syntax in the crontab file.

[minutes] [hour] [day] [month] [day of week] [command]

the fields are recognized with values as follows:

  • minutes = 0-59
  • hour = 0-23
  • day = 1-31
  • month = 1-12
  • day of week= 0-7, also recognized symbolically (SUN, MON, TUE, etc). 0=7=SUN.

* = any of these areas can be replaced with any output
*/5 = every five minutes

to send your output to a file, append the following to your job

>>/tmp/nameoffile.log 2>>/tmp/errors.log 3>>/tmp/weirdoutputformat.aksldf;j

> will write to a file and overwrite. >> will append to a file.


30 17 * * TUE,FRI rm -f /tmp/nameoffile.log /tmp/errors.log

is a cron job to delete your very old log files every tuesday and friday at 5:30 PM.

if your computer is not on at the time speciified for cron jobs, they will not be run. anacron is a program that will run in addition to cron and will perform and cron jobs that were missed on startup. anacron may not be included by default on all distributions.

note that daylight savings time happens twice a year. this confuses cron. therefore it is suggested that you not set any jobs between 1-3 AM.

if you wish to schedule one single-time job, use at instead with the syntax

at [time]

time is accepted in almost any syntax. "at teatime tomorrow" will be recognized as 4 PM tomorrow. "at teatime tomorrow - 10 minutes" will also work, sending something instead at 3:50 PM. "at now + 6 minutes" sets a job 6 minutes from now.

this will produce a prompt at which you should enter your command, such as

> echo "It's Teatime" | mail -f

which will send an email saying "It's Teatime" to some unsuspecting idiot. to exit at and register your job use CTRL+D.

atq will display a list of jobs that are on queue to be performed.

atrm [job #] is a command which removes the job at the specified number in at's job queue.

there is no recourse if your computer happens to be off when at is scheduled to run a job.


dailystrips is a program that automatically fetches comics for you.

dailystrips is available on ubuntu and debian as a package accessible from aptitude or synaptic.

to access comics, run the command

dailystrips [-l] <comics>

the -l flag indicates that the comics should be downloaded as opposed to hotlinked.

<comics> is a list of comics such as

dailystrips -l dilbert userfriendly apod

comics can be read from a browser reading from the directory where the comics are dumped. this can easily be added to your favorites tab.

there is a definitions file for dailystrips at usr/share/dailystrips/strips.def. in the definitions file you can specify how to get each strip and the director in which to dump them.

strip apod
 name Astronomy Picture of the Day
 type search
 searchpattern <regex, usually html>
 baseurl $homepage
 provides latest
strip apod
 name Sherman's Lagoon
 artist Jim tooney
 type generate
 referer <url; necessary for sites that require a referral as security for their images>
 imageurl <url with %m, %d, %y tags; excellent for sites with a predictable url>
 provides any
 filesuffix .gif

some comics are distributed through their syndicates' websites. these sometimes use specific classes which simplifies the syntax extensively.

this can be run with cron on a daily basis.

Native Linux Games

linuxlinks has a page listing 42 of best free linux games. also see ubuntu gamers arena. most of the best looking games are FPS in nature...

some interesting games discussed, with brief descriptions where appropriate:

  • urban terror - FPS, developed as a mod for quake 3 (but now does not require quake 3). 10K players/day. online/LAN multiplayer modes only. probably not too graphics intensive on lower settings. free, but not open source.
  • unknown horizons - settlement-building game, set in colonial times. has a not-yet-implemented multiplayer mode.
  • teeworlds - 2D action shooter game. multiplayer lots of weird stuff.
  • savage 2: a tortured soul - originally a commercial game, now free. combines RTS and RPG/FPS elements; commander is a real person who suggests to other players that they do these other things. this looks like an extremely cool game.
  • nexuiz - very polished FPS.
  • sauerbraten - another FPS, also has a co-op map editing mode (kind of like Garry's Mod, in some ways)
  • alien arena - another FPS. somewhat like nexuiz.
  • battle for wesnoth - a turn-based strategy game. isometric and marginal on graphics, but very interesting game and good mechanics; comparison made to game called fire emblem.
  • frozen bubble - puzzle game
  • wormux - worms clone
  • warzone2100 - some RTS
  • warsaw - another FPS, very high skill.
  • heroes of newerth - nonfree; $30, good graphics, written natively for linux, integrates RPG and other elements.
  • tremulous - another FPS
  • world of goo
  • and many more

Tiling window managers

non-WIMP (windows icons, mouse + pointer)

intended to not have things fit awkwardly on screen and still use the entire screen in logical columns. interface does not require the use of a mouse

two primary types of tiling window managers

  • master window (dwm in C; xmonad in haskell, extensible)
  • individual column manipulations (wmii)

tiling window managers have various workspaces like any other environment

other various commands requiring a learning curve

in wmii:

various different formatting options, including stacking, various columns, repositioning things, etc.

optional plan 9 component

floating mode (ie, especially useful with applications like GIMP, also has any functionality for resizing windows)

many other features and scriptability

Backup strategies

Basic reasons for data loss:

  • Drive failure
  • Human error
  • Natural disaster/theft


RAID = Redundant Array of Independent/Inexpensive Disks

multiple hard drives for storing data

RAID1: two hard drives; the system thinks that both drives are the same drive. The system simply mirrors one drive on the other. This protects against drive failure.

RAID5: s(n-1) capacity, where s = size of smallest hard drive, n = number of drives. Any one drive can fail at a time.

RAID can be implemented in hardware or in software. Operating system need not know that any RAID is going on in a hardware implementation, though this requires specialized, expensive hardware.

Software RAID -- less efficient than hardware because software does the RAID calculations.

RAID is only a backup solution for the case of drive failure; if human error or natural disaster/theft are of importance, then RAID is not a sufficient backup solution.

RAID is very nice because since there are redundant drives, there is generally little to no downtime, and the downtime that does occur can be scheduled at the convenience ofv the user. Some RAID arrays even have hotswappable drives, where the drives can be switched while the system is still running; such arrays have no downtime at all.

One issue with RAID is that large hard drives, upon failing, may have nontrivial chances of having the other drives fail during the write process to repopulate the array.

Filesystem Mirroring

Copy everything from first hard drive to backup hard drive. rsync is a program that will copy only the parts of files that have changed. This offers some protection for human error (24 hour window to correct errors). In the case of hard drive failure, this fails to preserve data loss in the time between backups.


Snapshots record the state of the file system at specified intervals, which describe how the filesystem looked at the time of the snapshot.

How do snapshots work? Hard links can ensure that files can be accessed and exist in different folders but refer only to the same file. Hard links can only exist on the same filesystem. Only files that have changed need be copied over. rsync has builtin support for snapshotting via hard links.

Another way of snapshotting -- use diffs; only creates machine representations that describe the specific changes in each file that was changed for each snapshot. This requires special tools to actually implement the changes when desired.

Snapshots protect against human error very effectively. Again, snapshots do not preserve data loss in the time between snapshots.


Backups are basically built in to ZFS. ZFS stores snapshots in the form of individual blocks that were changed; the files are thus represented on the filesystem discontiguously. This filesystem thus is nothing like traditional filesystems.

ZFS is currently only supported for solaris and may someday be supported for BSD; it will never be supported for linux due to incompatibility with the GPL license.

Offsite backups

All of the above solutions may protect for drive failure and human error, but not for natural disaster/theft. One traditional solution for offsite backups is the storage of data in removable media such as tapes to be stored at a secure location.

Another, less substantial version of this solution is the use of external hard drives.

Encryption may be a desirable feature in offsite backups.

Cloud backups

rsync can actually work over a network. This can be used to store all data on some other remote machine, though it requires a good connection in both areas.

Some services for cloud backups:

Crashplan - unlimited, free

Backblaze - unlimited, $5/mo

This requires some degree of trust that these services are from reliable companies whose data themselves will not fail and that they will not mess with your data (again, encryption may be desirable).

Another issue is bandwidth limitations -- many residential connections have high download speeds but crappy upload speeds. Initial uploads thus can take unreasonably long times, depending on the strength of the connection.

Using Linux at Brown (Sep 7, 2010)

Personal tools