Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

dzen2 is a notification utility of sorts. This command will make a notification that says "Hi" appear on the screen:

echo Hi | dzen2 -p

Debian's at is a utility that schedules events to occur in the future. This command will make the file "foo" appear in your user directory after 1 minute:

echo "touch ~/foo" | at now + 1 minute

So why is it that this command doesn't cause a dzen2 notification to appear after 1 minute?

echo "echo Hi | dzen2 -p" | at now + 1 minute

I have been investigating for hours and cannot seem to find a reason why this doesn't work! I have a hunch that it has to do with the shell that is invoked by at, but I just don't understand why it fails. As a counterpoint example, this command works just fine:

echo "notify-send Hi" | at now + 1 minute
share|improve this question
may have something to do with the $DISPLAY variable, but i don't know the details of at. someone else should chim in – llua May 10 '12 at 23:53
up vote 6 down vote accepted

The program that constitutes the at job is a child of the atd (at daemon) process, not of the shell where you run at. So it does not inherit the current shell's environment. The at system arranges to copy the environment (and the working directory and a few more obscure thing), but it omits a few variables.

In particular, the DISPLAY variable is not copied to the at job. This variable tells all X programs which display to connect to. Without an X display, dzen2 doesn't know where to pop up a notification. At removes DISPLAY because it's usually used for batch jobs, which do not produce any terminal or graphical output.

notify-send works because it doesn't connect to the X server: it uses D-bus to connect to a daemon that is attached to your X session.

You can make dzen2 work by explicitly copying the DISPLAY variable:

echo "export DISPLAY=$DISPLAY;" 'echo hello | dzen2 -p' | at now + 42 minutes

It's likely that dzen2 produces an error message (the standard message is Can't open display:). Any output or error message produced by the at job is sent by local mail (exactly like for cron jobs). Check your local mail.

share|improve this answer
Gilles to the rescue. It is no wonder you have 87k reputation! I know you have saved me on more than a few of my own questions. Thumbs up to you, man, and thanks again. – Cory Klein May 11 '12 at 15:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.