1

This question already has an answer here:

Is there any way I can clear the X clipboard from a cron job? The usual commands for xclip don't seem to work.

echo -n | xclip -selection clipboard

doesn't work from cron.

marked as duplicate by Gilles, G-Man, eyoung100, slm Aug 5 '15 at 1:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

X programs use DISPLAYs to work out what X11 instance to apply the program to. If you are the sole user of your host then most likely your display will be localhost:0 or often abbreviated to :0. you can find your DISPLAY variable by using:

echo ${DISPLAY}

To tell xclip to use that display, issue the -display command line option, or set the the DISPLAY environment variable

echo -n | xclip -display :0 -selection clipboard
  • A good answer, except that the default display is usually :0, and trying to use :1 will result in an error. – larsks Aug 4 '15 at 12:31
  • Bad habbits! (I always have two X sessions, one is a VNC instance, and the other I rarely use). I should know better! I will update - thanks! – Drav Sloan Aug 4 '15 at 12:34

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