Search code examples
bashcron

Run graphic content with crontab (xcowsay)


I'm trying to open a random fortune every hour with xcowsay, the problem is that I tried to set the DISPLAY environment variable before running the command:

* * * * * export DISPLAY=:0 && fortune -a | xcowsay

But it doesn't work, I've tried to launch it with a script but it doesn't change anything, the cow doesn't show up and there is nothing.

Do you have any advice ?

Thank you by advance


Solution

  • There are two problems:

    • crontab only expects one command. It cannot invoke multiple commands with pipe.
    • crontab doesn't know the path to fortune and xcowsay.

    Then would you please try instead:

    * * * * * bash -c 'export DISPLAY=:0 && /usr/games/fortune -a | /usr/games/xcowsay'